From e2a9d86deef247e3267c44df0b9330abbb78a75b Mon Sep 17 00:00:00 2001 From: Erwan Carriou Date: Fri, 7 Jun 2019 23:19:58 +0200 Subject: [PATCH] Bump 3.5.3 --- .gitignore | 11 ++--------- designer/lib/designer/vendor.js | 14 +++++++------- designer/scripts/diagram.js | 2 +- designer/scripts/editor-behavior.js | 2 +- designer/scripts/editor-component.js | 2 +- designer/scripts/editor-model.js | 2 +- designer/scripts/editor-schema.js | 2 +- designer/scripts/editor-system.js | 2 +- designer/scripts/editor-type.js | 2 +- designer/scripts/system-designer.js | 2 +- package-lock.json | 2 +- package.json | 3 ++- scripts/linux.js | 2 +- scripts/macos.js | 4 ++-- scripts/windows.js | 2 +- 15 files changed, 24 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 9183d2e..f197a62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,7 @@ npm-debug.log* node_modules -.node_repl_history - -# designated output directory -# less to specify ignoring after packager run -# (change to reflect) electron-packager --out switch dist - -# ignore MacOS Finder dotfiles +scripts/mas.js +.node_repl_history .DS_Store - -# ignore directory-specific settings (e.g. "Show Hidden Files") in Linux .directory diff --git a/designer/lib/designer/vendor.js b/designer/lib/designer/vendor.js index fc81279..45bf83a 100644 --- a/designer/lib/designer/vendor.js +++ b/designer/lib/designer/vendor.js @@ -973,13 +973,13 @@ Prism.languages.js = Prism.languages.javascript; })(); -(function(){function a(a,b){return[-a[0][b]+3*a[1][b]+-3*a[2][b]+a[3][b],3*a[0][b]-6*a[1][b]+3*a[2][b],-3*a[0][b]+3*a[1][b],a[0][b]]}function b(b){return[a(b,"x"),a(b,"y")]}function c(a){return 0>a?-1:a>0?1:0}function d(a,b,d,e){var f,g,h=b/a,i=d/a,j=e/a,k=(3*i-Math.pow(h,2))/9,l=(9*h*i-27*j-2*Math.pow(h,3))/54,m=Math.pow(k,3)+Math.pow(l,2),n=[];if(m>=0)f=c(l+Math.sqrt(m))*Math.pow(Math.abs(l+Math.sqrt(m)),1/3),g=c(l-Math.sqrt(m))*Math.pow(Math.abs(l-Math.sqrt(m)),1/3),n[0]=-h/3+(f+g),n[1]=-h/3-(f+g)/2,n[2]=-h/3-(f+g)/2,0!==Math.abs(Math.sqrt(3)*(f-g)/2)&&(n[1]=-1,n[2]=-1);else{var o=Math.acos(l/Math.sqrt(-Math.pow(k,3)));n[0]=2*Math.sqrt(-k)*Math.cos(o/3)-h/3,n[1]=2*Math.sqrt(-k)*Math.cos((o+2*Math.PI)/3)-h/3,n[2]=2*Math.sqrt(-k)*Math.cos((o+4*Math.PI)/3)-h/3}for(var p=0;3>p;p++)(n[p]<0||n[p]>1)&&(n[p]=-1);return n}"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var e={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},f=64,g=Math.pow(2,-f-1),h=function(a,b){for(var c=[],d=j(a,b),f=b.length-1,g=2*f-1,h=k(d,g,c,0),i=e.subtract(a,b[0]),l=e.square(i),m=0,n=0;h>n;n++){i=e.subtract(a,o(b,f,c[n],null,null));var p=e.square(i);l>p&&(l=p,m=c[n])}return i=e.subtract(a,b[f]),p=e.square(i),l>p&&(l=p,m=1),{location:m,distance:l}},i=function(a,b){var c=h(a,b);return{point:o(b,b.length-1,c.location,null,null),location:c.location}},j=function(a,b){for(var c=b.length-1,d=2*c-1,f=[],g=[],h=[],i=[],j=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],k=0;c>=k;k++)f[k]=e.subtract(b[k],a);for(var k=0;c-1>=k;k++)g[k]=e.subtract(b[k+1],b[k]),g[k]=e.scale(g[k],3);for(var l=0;c-1>=l;l++)for(var m=0;c>=m;m++)h[l]||(h[l]=[]),h[l][m]=e.dotProduct(g[l],f[m]);for(k=0;d>=k;k++)i[k]||(i[k]=[]),i[k].y=0,i[k].x=parseFloat(k)/d;for(var n=c,o=c-1,p=0;n+o>=p;p++){var q=Math.max(0,p-o),r=Math.min(p,n);for(k=q;r>=k;k++){var s=p-k;i[k+s].y+=h[s][k]*j[s][k]}}return i},k=function(a,b,c,d){var e,g,h=[],i=[],j=[],p=[];switch(l(a,b)){case 0:return 0;case 1:if(d>=f)return c[0]=(a[0].x+a[b].x)/2,1;if(m(a,b))return c[0]=n(a,b),1}o(a,b,.5,h,i),e=k(h,b,j,d+1),g=k(i,b,p,d+1);for(var q=0;e>q;q++)c[q]=j[q];for(var q=0;g>q;q++)c[q+e]=p[q];return e+g},l=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},m=function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;var t,u;t=u=0;for(var v=1;b>v;v++){var w=i*a[v].x+j*a[v].y+k;w>t?t=w:u>w&&(u=w)}return n=0,o=1,p=0,q=i,r=j,s=k-t,l=n*r-q*o,m=1/l,d=(o*s-r*p)*m,q=i,r=j,s=k-u,l=n*r-q*o,m=1/l,e=(o*s-r*p)*m,f=Math.min(d,e),h=Math.max(d,e),c=h-f,g>c?1:0},n=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},o=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},p={},q=function(a){var b=p[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(b){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),p[a]=b}return b},r=function(a,b){for(var c=q(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=r(a,d),c+=s(f,b),b=f;return c},w=function(a,b,c){return u(a,b,c).point},x=function(a,b,c){return u(a,b,c).location},y=function(a,b){var c=r(a,b),d=r(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0===e?1/0:Math.atan(e/f)},z=function(a,b,c){var d=u(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),y(a,d.location)},A=function(a,b,c,d){d=null==d?0:d;var e=u(a,b,d),f=y(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]},B=function(a,c,e,f,g){var h=f-c,i=a-e,j=a*(c-f)+c*(e-a),k=b(g),l=[h*k[0][0]+i*k[1][0],h*k[0][1]+i*k[1][1],h*k[0][2]+i*k[1][2],h*k[0][3]+i*k[1][3]+j],m=d.apply(null,l),n=[];if(null!=m)for(var o=0;3>o;o++){var p,q=m[o],r=Math.pow(q,2),s=Math.pow(q,3),t=[k[0][0]*s+k[0][1]*r+k[0][2]*q+k[0][3],k[1][0]*s+k[1][1]*r+k[1][2]*q+k[1][3]];p=e-a!==0?(t[0]-a)/(e-a):(t[1]-c)/(f-c),q>=0&&1>=q&&p>=0&&1>=p&&n.push(t)}return n},C=function(a,b,c,d,e){var f=[];return f.push.apply(f,B(a,b,a+c,b,e)),f.push.apply(f,B(a+c,b,a+c,b+d,e)),f.push.apply(f,B(a+c,b+d,a,b+d,e)),f.push.apply(f,B(a,b+d,a,b,e)),f},D=function(a,b){var c=[];return c.push.apply(c,B(a.x,a.y,a.x+a.w,a.y,b)),c.push.apply(c,B(a.x+a.w,a.y,a.x+a.w,a.y+a.h,b)),c.push.apply(c,B(a.x+a.w,a.y+a.h,a.x,a.y+a.h,b)),c.push.apply(c,B(a.x,a.y+a.h,a.x,a.y,b)),c},E=this.jsBezier={distanceFromCurve:h,gradientAtPoint:y,gradientAtPointAlongCurveFrom:z,nearestPointOnCurve:i,pointOnCurve:r,pointAlongCurveFrom:w,perpendicularToCurveAt:A,locationAlongCurveFrom:x,getLength:v,lineIntersection:B,boxIntersection:C,boundingBoxIntersection:D,version:"0.9.0"};"undefined"!=typeof exports&&(exports.jsBezier=E)}).call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.Biltong={version:"0.4.0"};"undefined"!=typeof exports&&(exports.Biltong=b);var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a,b,d){return a=c(a)?a:[a.x,a.y],b=c(b)?b:[b.x,b.y],d(a,b)},e=b.gradient=function(a,b){return d(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-(1/0):b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},f=(b.normal=function(a,b){return-1/e(a,b)},b.lineLength=function(a,b){return d(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},b.quadrant=function(a,b){return d(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),g=(b.theta=function(a,b){return d(a,b,function(a,b){var c=e(a,b),d=Math.atan(c),g=f(a,b);return(4==g||3==g)&&(d+=Math.PI),0>d&&(d+=2*Math.PI),d})},b.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},b.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),h=[null,[-1,-1],[-1,1],[1,1],[1,-1]];b.pointOnLine=function(a,b,c){var d=e(a,b),i=f(a,b),j=c>0?g[i]:h[i],k=Math.atan(d),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},b.perpendicularLineTo=function(a,b,c){var d=e(a,b),f=Math.atan(-1/d),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call("undefined"!=typeof window?window:this),function(){"use strict";function a(a,b,c,d,e,f,g,h){return new Touch({target:b,identifier:J(),pageX:c,pageY:d,screenX:e,screenY:f,clientX:g||e,clientY:h||f})}function b(){var a=[];return Array.prototype.push.apply(a,arguments),a.item=function(a){return this[a]},a}function c(c,d,e,f,g,h,i,j){return b(a.apply(null,arguments))}var d=this,e=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>x,z=function(a,b){if(null==a)return[0,0];var c=E(a),d=D(c,0);return[d[b+"X"],d[b+"Y"]]},A=function(a){return null==a?[0,0]:y?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:z(a,"page")},B=function(a){return z(a,"screen")},C=function(a){return z(a,"client")},D=function(a,b){return a.item?a.item(b):a[b]},E=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},F=function(a){return E(a).length},G=function(a,b,c,d){if(k(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},H=function(a,b,c){null!=c&&I(a,function(){var d=f(this);if(l(d,b,c),null!=c.__tauid)if(d.removeEventListener)d.removeEventListener(b,c,!1),u&&w[b]&&d.removeEventListener(w[b],c,!1);else if(this.detachEvent){var e=b+c.__tauid;d[e]&&d.detachEvent("on"+b,d[e]),d[e]=null,d["e"+e]=null}c.__taTouchProxy&&H(a,c.__taTouchProxy[1],c.__taTouchProxy[0])})},I=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c-1&&9>j,n=9===j,o=function(a){if(m)return[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop];var b=q(a),c=p(b,0);return n?[c.pageX||c.clientX,c.pageY||c.clientY]:[c.pageX,c.pageY]},p=function(a,b){return a.item?a.item(b):a[b]},q=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},r={delegatedDraggable:"katavorio-delegated-draggable",draggable:"katavorio-draggable",droppable:"katavorio-droppable",drag:"katavorio-drag",selected:"katavorio-drag-selected",active:"katavorio-drag-active",hover:"katavorio-drag-hover",noSelect:"katavorio-drag-no-select",ghostProxy:"katavorio-ghost-proxy",clonedDrag:"katavorio-clone-drag"},s="katavorio-drag-scope",t=["stop","start","drag","drop","over","out","beforeStart"],u=function(){},v=function(){return!0},w=function(a,b,c){for(var d=0;d0){var e=i(O,this.el,a.target||a.srcElement);if(null!=e&&(P=e[0],N=e[1]),null==N)return}else N=this.el;if(G)if(F=N.cloneNode(!0),this.params.addClass(F,r.clonedDrag),F.setAttribute("id",null),F.style.position="absolute",null!=this.params.parent){var g=this.params.getPosition(this.el);F.style.left=g[0]+"px",F.style.top=g[1]+"px",this.params.parent.appendChild(F)}else{var j=f(N);F.style.left=j.left+"px",F.style.top=j.top+"px",document.body.appendChild(F)}else F=N;A&&z(a),q=o(a),F&&F.parentNode&&(y=[F.parentNode.scrollLeft,F.parentNode.scrollTop]),this.params.bind(document,"mousemove",this.moveListener),this.params.bind(document,"mouseup",this.upListener),h.markSelection(this),h.markPosses(this),this.params.addClass(document.body,c.noSelect),ea("beforeStart",{el:this.el,pos:s,e:a,drag:this})}else this.params.consumeFilteredEvents&&z(a)}}}.bind(this),this.moveListener=function(a){if(q){if(!w){var b=ea("start",{el:this.el,pos:s,e:a,drag:this});if(b!==!1){if(!q)return;this.mark(!0),w=!0}else this.abort()}if(q){ca.length=0;var c=o(a),d=c[0]-q[0],e=c[1]-q[1],f=this.params.ignoreZoom?1:h.getZoom();F&&F.parentNode&&(d+=F.parentNode.scrollLeft-y[0],e+=F.parentNode.scrollTop-y[1]),d/=f,e/=f,this.moveBy(d,e,a),h.updateSelection(d,e,this),h.updatePosses(d,e,this)}}}.bind(this),this.upListener=function(a){q&&(q=null,this.params.unbind(document,"mousemove",this.moveListener),this.params.unbind(document,"mouseup",this.upListener),this.params.removeClass(document.body,c.noSelect),this.unmark(a),h.unmarkSelection(this,a),h.unmarkPosses(this,a),this.stop(a),h.notifyPosseDragStop(this,a),w=!1,ca.length=0,G?(F&&F.parentNode&&F.parentNode.removeChild(F),F=null):X&&X(F,this.params.getPosition(F))===!0&&(this.params.setPosition(F,s),ea("revert",F)))}.bind(this),this.getFilters=function(){return Z},this.abort=function(){null!=q&&this.upListener()},this.getDragElement=function(a){return a?N||this.el:F||this.el};var da={start:[],drag:[],stop:[],over:[],out:[],beforeStart:[],revert:[]};b.events.start&&da.start.push(b.events.start),b.events.beforeStart&&da.beforeStart.push(b.events.beforeStart),b.events.stop&&da.stop.push(b.events.stop),b.events.drag&&da.drag.push(b.events.drag),b.events.revert&&da.revert.push(b.events.revert),this.on=function(a,b){da[a]&&da[a].push(b)},this.off=function(a,b){if(da[a]){for(var c=[],d=0;d0)for(var f=0;f0&&fa&&b.setPosition(N,fa),ca.sort(I);for(var e=0;eb.rank?-1:0},J=function(a){return null==a?null:(a="string"==typeof a||a.constructor===String?document.getElementById(a):a,null==a?null:(a._katavorio=a._katavorio||H(),a))};a.Katavorio=function(a){var f=[],g={};this._dragsByScope={},this._dropsByScope={};var h=1,i=function(a,b){y(a,function(a){for(var c=0;c0},k=(this.getMatchingDroppables=function(a){for(var b=[],c={},d=0;d=0&&f.splice(d,1),j(a[b],c)&&y(a[b],function(a){a.destroy()}),delete a[b]}},B=function(a,b,c,d){a=J(a),a[b]&&a[b].off(c,d)};this.elementRemoved=function(a){this.destroyDraggable(a),this.destroyDroppable(a)},this.destroyDraggable=function(a,b,c){1===arguments.length?z(a,"_katavorioDrag",this._dragsByScope):B(a,"_katavorioDrag",b,c)},this.destroyDroppable=function(a,b,c){1===arguments.length?z(a,"_katavorioDrop",this._dropsByScope):B(a,"_katavorioDrop",b,c)},this.reset=function(){this._dragsByScope={},this._dropsByScope={},f=[],g={},C={}};var C={},D=function(a,c,d){var f=e(c)?c:c.id,g=e(c)?!0:c.active!==!1,h=C[f]||function(){var a={name:f,members:[]};return C[f]=a,a}();return y(a,function(a){if(a._katavorioDrag){if(d&&null!=a._katavorioDrag.posseRoles[h.name])return;b(h.members,a._katavorioDrag),b(a._katavorioDrag.posses,h.name),a._katavorioDrag.posseRoles[h.name]=g}}),h};this.addToPosse=function(a,b){for(var c=[],d=1;d0}function j(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}function k(b){if(c(b))return""+b;if(d(b))return!!b;if(g(b))return new Date(b.getTime());if(h(b))return b;if(a(b)){for(var e=[],i=0;i=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}();return""}),a}}function n(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!==c}function r(a,b){var c=a.indexOf(b);return c>-1&&a.splice(c,1),-1!==c}function s(a,b,c){-1===p(a,c)&&a.push(b)}function t(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e}function u(a,b,c){return-1===a.indexOf(b)?(c?a.unshift(b):a.push(b),!0):!1}function v(b,c,d){var e;c=a(c)?c:[c];var f=function(a){for(var c=a.__proto__;null!=c;)if(null!=c.prototype){for(var d in c.prototype)c.prototype.hasOwnProperty(d)&&!b.prototype.hasOwnProperty(d)&&(b.prototype[d]=c.prototype[d]);c=c.prototype.__proto__}else c=null};for(e=0;e2)for(e=2;ee&&g!==!1;){if(this.eventsToDieOn[a])this._listeners[a][e].apply(this,[b,c]);else try{g=this._listeners[a][e].apply(this,[b,c])}catch(h){B("jsPlumb: fire failed for event "+a+" : "+h)}e++,(null==this._listeners||null==this._listeners[a])&&(f=!0)}}this.tick=!1,this._drain()}return this},this._drain=function(){var b=a.queue.pop();b&&a.fire.apply(a,b)},this.unbind=function(a,b){if(0===arguments.length)this._listeners={};else if(1===arguments.length){if("string"==typeof a)delete this._listeners[a];else if(a.__jsPlumb){var c=void 0;for(var d in a.__jsPlumb)c=a.__jsPlumb[d],r(this._listeners[c]||[],a)}}else 2===arguments.length&&r(this._listeners[a]||[],b);return this},this.getListener=function(b){return a._listeners[b]},this.setSuspendEvents=function(b){a.eventsSuspended=b},this.isSuspendEvents=function(){return a.eventsSuspended},this.silently=function(b){a.setSuspendEvents(!0);try{b()}catch(c){B("Cannot execute silent function "+c)}a.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a._listeners)a._listeners[b]=null}}return a}();E.EventGenerator=F}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this;a.jsPlumbUtil.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ef;f++)d&&d===e[f]||e[f].setHover(b,!0,c)},g=function(a){return null==a?null:a.split(" ")},h=function(a,b,c){for(var d in b)a[d]=c},i=function(a,c,d){if(a.getDefaultType){var e=a.getTypeDescriptor(),f={},g=a.getDefaultType(),i=b.merge({},g);h(f,g,"__default");for(var j=0,k=a._jsPlumb.types.length;k>j;j++){var l=a._jsPlumb.types[j];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(i=b.merge(i,m,["cssClass"],["connector"]),h(f,m,l))}}c&&(i=b.populate(i,c,"_")),a.applyType(i,d,f),d||a.repaint()}},j=a.jsPlumbUIComponent=function(a){b.EventGenerator.apply(this,arguments);var c=this,d=arguments,e=c.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&i(this,b,c)}},removeType:function(a,b,c){var d=g(a),e=!1,f=function(a){var b=this._jsPlumb.types.indexOf(a);return-1!==b?(k(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=d){for(var h=0,j=d.length;j>h;h++)e=f(d[h])||e;e&&i(this,b,c)}},clearTypes:function(a,b){for(var c=this._jsPlumb.types.length,d=0;c>d;d++)k(this,0),this._jsPlumb.types.splice(0,1);i(this,a,b)},toggleType:function(a,b,c){var d=g(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var h=this._jsPlumb.types.indexOf(d[e]);-1!==h?(k(this,h),this._jsPlumb.types.splice(h,1)):this._jsPlumb.types.push(d[e])}i(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,d(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,d(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,d){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){this._jsPlumb.hover=a;var e=a?"addClass":"removeClass";null!=this.canvas&&(null!=this._jsPlumb.instance.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.instance.hoverClass),null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.hoverClass)),null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(d=d||c(),this.repaint({timestamp:d,recalc:!1}))),this.getAttachedElements&&!b&&f(this,a,c(),this)}}});var l=0,m=function(){var a=l+1;return l++,a},n=a.jsPlumbInstance=function(d){this.version="2.9.3",this.Defaults={Anchor:"Bottom",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fill:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{"stroke-width":4,stroke:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},d&&o.extend(this.Defaults,d),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},b.EventGenerator.apply(this);var f=this,g=m(),h=f.bind,i={},k=1,l=function(a){if(null==a)return null;if(3===a.nodeType||8===a.nodeType)return{el:a,text:!0};var c=f.getElement(a);return{el:c,id:b.isString(a)&&null==c?a:T(c)}};this.getInstanceIndex=function(){return g},this.setZoom=function(a,b){return k=a,f.fire("zoom",k),b&&f.repaintEverything(),!0},this.getZoom=function(){return k};for(var n in this.Defaults)i[n]=this.Defaults[n];var p,q=[];this.unbindContainer=function(){if(null!=p&&q.length>0)for(var a=0;ae;e++)d.overlays.push(d.sourceEndpoint.connectorOverlays[e])}d.sourceEndpoint&&d.sourceEndpoint.scope&&(d.scope=d.sourceEndpoint.scope),!d["pointer-events"]&&d.sourceEndpoint&&d.sourceEndpoint.connectorPointerEvents&&(d["pointer-events"]=d.sourceEndpoint.connectorPointerEvents);var h=function(a,b,c){return f.addEndpoint(a,K(b,{anchor:d.anchors?d.anchors[c]:d.anchor,endpoint:d.endpoints?d.endpoints[c]:d.endpoint,paintStyle:d.endpointStyles?d.endpointStyles[c]:d.endpointStyle,hoverPaintStyle:d.endpointHoverStyles?d.endpointHoverStyles[c]:d.endpointHoverStyle}))},i=function(a,b,c,e){if(d[a]&&!d[a].endpoint&&!d[a+"Endpoint"]&&!d.newConnection){var f=T(d[a]),g=c[f];if(g=g?g[e]:null){if(!g.enabled)return!1;var i=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:h(d[a],g.def,b);if(i.isFull())return!1;d[a+"Endpoint"]=i,!d.scope&&g.def.scope&&(d.scope=g.def.scope),g.uniqueEndpoint?g.endpoint?i.finalEndpoint=g.endpoint:(g.endpoint=i,i.setDeleteOnEmpty(!1)):i.setDeleteOnEmpty(!0),0===b&&g.def.connectorOverlays&&(d.overlays=d.overlays||[],Array.prototype.push.apply(d.overlays,g.def.connectorOverlays))}}};return i("source",0,this.sourceEndpointDefinitions,d.type||"default")!==!1&&i("target",1,this.targetEndpointDefinitions,d.type||"default")!==!1?(d.sourceEndpoint&&d.targetEndpoint&&(J(d.sourceEndpoint,d.targetEndpoint)||(d=null)),d):void 0}.bind(f),M=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=M,a.newEndpoint=O,a.endpointsByUUID=v,a.endpointsByElement=u,a.finaliseConnection=N,a.id="con_"+F();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable("_jsPlumbSource"),c.endpoints[1].initDraggable("_jsPlumbTarget")),c},N=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||t.push(a),a.pending=null,a.endpoints[0].isTemporarySource=!1,d!==!1&&f.anchorManager.newConnection(a),H(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},O=function(a,b){var c=f.Defaults.EndpointType||o.Endpoint,d=o.extend({},a);d._jsPlumb=f,d.newConnection=M,d.newEndpoint=O,d.endpointsByUUID=v,d.endpointsByElement=u,d.fireDetachEvent=W,d.elementId=b||T(d.source);var e=new c(d);return e.id="ep_"+F(),na(d.elementId,d.source),o.headless||f.getDragManager().endpointAdded(d.source,b),e},P=function(a,b,c){var d=u[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},Q=function(a,b,c){b="block"===b;var d=null;c&&(d=function(a){a.setVisible(b,!0,!0)});var e=l(a);P(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},R=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),P(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},S=function(a){var b=x[a];return b?{o:b,s:A[a]}:oa({elId:a})},T=function(a,c,d){if(b.isString(a))return a;if(null==a)return null;var e=f.getAttribute(a,"id");return e&&"undefined"!==e||(2===arguments.length&&void 0!==arguments[1]?e=c:(1===arguments.length||3===arguments.length&&!arguments[2])&&(e="jsPlumb_"+g+"_"+F()),d||f.setAttribute(a,"id",e)),e};this.setConnectionBeingDragged=function(a){z=a},this.isConnectionBeingDragged=function(){return z},this.getManagedElements=function(){return w},this.connectorClass="jtk-connector",this.connectorOutlineClass="jtk-connector-outline",this.connectedClass="jtk-connected",this.hoverClass="jtk-hover",this.endpointClass="jtk-endpoint",this.endpointConnectedClass="jtk-endpoint-connected",this.endpointFullClass="jtk-endpoint-full",this.endpointDropAllowedClass="jtk-endpoint-drop-allowed",this.endpointDropForbiddenClass="jtk-endpoint-drop-forbidden",this.overlayClass="jtk-overlay",this.draggingClass="jtk-dragging",this.elementDraggingClass="jtk-element-dragging",this.sourceElementDraggingClass="jtk-source-element-dragging",this.targetElementDraggingClass="jtk-target-element-dragging",this.endpointAnchorClassPrefix="jtk-endpoint-anchor",this.hoverSourceClass="jtk-source-hover",this.hoverTargetClass="jtk-target-hover",this.dragSelectClass="jtk-drag-select",this.Anchors={},this.Connectors={svg:{}},this.Endpoints={svg:{}},this.Overlays={svg:{}},this.ConnectorRenderers={},this.SVG="svg",this.addEndpoint=function(a,c,d){d=d||{};var e=o.extend({},d);o.extend(e,c),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=b.isArray(a)||null!=a.length&&!b.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),la(e.source);var k=T(e.source),l=O(e,k),m=na(k,e.source).info.o;b.addToList(u,k,l),B||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:A[k],element:l,timestamp:C}),timestamp:C}),g.push(l)}return 1===g.length?g[0]:g},this.addEndpoints=function(a,c,d){for(var e=[],g=0,h=c.length;h>g;g++){var i=f.addEndpoint(a,c[g],d);b.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,c,d){if(!this.animationSupported)return!1;d=d||{};var e=f.getElement(a),g=T(e),h=o.animEvents.step,i=o.animEvents.complete;d[h]=b.wrap(d[h],function(){f.revalidate(g)}),d[i]=b.wrap(d[i],function(){f.revalidate(g)}),f.doAnimate(e,c,d)},this.checkCondition=function(a,c){var d=f.getListener(a),e=!0;if(d&&d.length>0){var g=Array.prototype.slice.call(arguments,1);try{for(var h=0,i=d.length;i>h;h++)e=e&&d[h].apply(d[h],g)}catch(j){b.log(f,"cannot check condition ["+a+"]"+j)}}return e},this.connect=function(a,c){var d,e=L(a,c);if(e){if(null==e.source&&null==e.sourceEndpoint)return void b.log("Cannot establish connection - source does not exist");if(null==e.target&&null==e.targetEndpoint)return void b.log("Cannot establish connection - target does not exist");la(e.source),d=M(e),N(d,e)}return d};var U=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],V=function(a,b,c,d){var e,f,g,h=U[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1===c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor===o.Endpoint)e=b,e.addConnection(a),b=e.element;else if(f=T(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g)for(var l in g){if(!g[l].enabled)return;e=null!=g[l].endpoint&&g[l].endpoint._jsPlumb?g[l].endpoint:this.addEndpoint(b,g[l].def),g[l].uniqueEndpoint&&(g[l].endpoint=e),e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f);return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,X(k),d||a.repaint()),k.element=b,k}.bind(this);this.setSource=function(a,b,c){var d=V(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a,d.el)},this.setTarget=function(a,b,c){var d=V(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b,c){var d="string"==typeof a?v[a]:a;return d&&f.deleteObject({endpoint:d,dontUpdateHover:b,deleteAttachedObjects:c}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in u){var c=u[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}u={},w={},v={},x={},y={},f.anchorManager.reset();var g=f.getDragManager();return g&&g.reset(),a||f.setSuspendDrawing(!1),f};var W=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor===d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.fire("internal.connectionDetached",g,c),f.anchorManager.connectionDetached(g)},X=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(v[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in u){var c=u[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!==a&&d.push(c[e]);u[b]=d}u[b].length<1&&delete u[b]}};var Y="isDetachAllowed",Z="beforeDetach",$="checkCondition";this.deleteConnection=function(a,c){return null!=a&&(c=c||{},c.force||b.functionChain(!0,!1,[[a.endpoints[0],Y,[a]],[a.endpoints[1],Y,[a]],[a,Y,[a]],[f,$,[Z,a]]]))?(a.setHover(!1),W(a,!a.pending&&c.fireEvent!==!1,c.originalEvent),a.endpoints[0].detachFromConnection(a),a.endpoints[1].detachFromConnection(a),b.removeWithFunction(t,function(b){return a.id===b.id}),a.cleanup(),a.destroy(),!0):!1},this.deleteEveryConnection=function(a){a=a||{};var b=t.length,c=0;return f.batch(function(){for(var d=0;b>d;d++)c+=f.deleteConnection(t[0],a)?1:0}),c},this.deleteConnectionsForElement=function(a,b){b=b||{},a=f.getElement(a);var c=T(a),d=u[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].deleteEveryConnection(b);return f},this.deleteObject=function(a){var c={endpoints:{},connections:{},endpointCount:0,connectionCount:0},d=a.deleteAttachedObjects!==!1,e=function(b){null!=b&&null==c.connections[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.connections[b.id]=b,c.connectionCount++)},g=function(b){if(null!=b&&null==c.endpoints[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.endpoints[b.id]=b,c.endpointCount++,d))for(var f=0;fe;e++)a[e][b].apply(a[e],c);return d(a)},aa=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},ba=function(a,b,c){return function(){return _(a,b,arguments,c)}},ca=function(a,b){return function(){return aa(a,b,arguments)}},da=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(l(a[d]).id);else c.push(l(a).id);return c},ea=function(a,b,c){return"*"===a?!0:a.length>0?-1!==a.indexOf(b):!c};this.getConnections=function(a,b){a?a.constructor===String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=da(c,!0),e=da(a.source),g=da(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=t.length;k>j;j++){var l=t[j],m=l.proxies&&l.proxies[0]?l.proxies[0].originalEp.elementId:l.sourceId,n=l.proxies&&l.proxies[1]?l.proxies[1].originalEp.elementId:l.targetId;ea(d,l.scope)&&ea(e,m)&&ea(g,n)&&i(l.scope,l)}return h};var fa=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},ga=function(a){return function(b){return a[b]}},ha=function(a,b){var c,d,e={length:a.length,each:fa(a,b),get:ga(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"]; -for(c=0,d=f.length;d>c;c++)e[f[c]]=ba(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=ca(a,g[c]);return e},ia=function(a){var b=ha(a,ia);return o.extend(b,{setDetachable:ba(a,"setDetachable",ia),setReattach:ba(a,"setReattach",ia),setConnector:ba(a,"setConnector",ia),"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteConnection(a[b])},isDetachable:ca(a,"isDetachable"),isReattach:ca(a,"isReattach")})},ja=function(a){var b=ha(a,ja);return o.extend(b,{setEnabled:ba(a,"setEnabled",ja),setAnchor:ba(a,"setAnchor",ja),isEnabled:ca(a,"isEnabled"),deleteEveryConnection:function(){for(var b=0,c=a.length;c>b;b++)a[b].deleteEveryConnection()},"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteEndpoint(a[b])}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",ia(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":da(a.element),d=b?"*":da(a.source),e=b?"*":da(a.target),f=da(a.scope,!0),g=[];for(var h in u){var i=ea(c,h,!0),j=ea(d,h,!0),k="*"!==d,l=ea(e,h,!0),m="*"!==e;if(i||j||l)a:for(var n=0,o=u[h].length;o>n;n++){var p=u[h][n];if(ea(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return ja(g)},this.getAllConnections=function(){return t},this.getDefaultScope=function(){return D},this.getEndpoint=I,this.getEndpoints=function(a){return u[l(a).id]||[]},this.getDefaultEndpointType=function(){return o.Endpoint},this.getDefaultConnectionType=function(){return o.Connection},this.getId=T,this.draw=H,this.info=l,this.appendElement=G;var ka=!1;this.isHoverSuspended=function(){return ka},this.setHoverSuspended=function(a){ka=a},this.hide=function(a,b){return Q(a,"none",b),f},this.idstamp=F;var la=function(a){if(!p&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ma=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},na=f.manage=function(a,b,c){return w[a]||(w[a]={el:b,endpoints:[],connections:[]},w[a].info=oa({elId:a,timestamp:C}),f.addClass(b,"jtk-managed"),c||f.fire("manageElement",{id:a,info:w[a].info,el:b})),w[a]},oa=(f.unmanage=function(a){w[a]&&(f.removeClass(w[a].el,"jtk-managed"),delete w[a],f.fire("unmanageElement",a))},function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return B&&!c&&(c=C),!d&&c&&c===y[g]?{o:a.offset||x[g],s:A[g]}:(d||!e&&null==x[g]?(b=w[g]?w[g].el:null,null!=b&&(A[g]=f.getSize(b),x[g]=f.getOffset(b),y[g]=c)):(x[g]=e||x[g],null==A[g]&&(b=w[g].el,null!=b&&(A[g]=f.getSize(b))),y[g]=c),x[g]&&!x[g].right&&(x[g].right=x[g].left+A[g][0],x[g].bottom=x[g].top+A[g][1],x[g].width=A[g][0],x[g].height=A[g][1],x[g].centerx=x[g].left+x[g].width/2,x[g].centery=x[g].top+x[g].height/2),{o:x[g],s:A[g]})});this.updateOffset=oa,this.init=function(){s||(ma(),f.anchorManager=new a.jsPlumb.AnchorManager({jsPlumbInstance:f}),s=!0,f.fire("ready",f))}.bind(this),this.log=r,this.jsPlumbUIComponent=j,this.makeAnchor=function(){var c,d=function(b,c){if(a.jsPlumb.Anchors[b])return new a.jsPlumb.Anchors[b](c);if(!f.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown anchor type '"+b+"'"}};if(0===arguments.length)return null;var e=arguments[0],g=arguments[1],h=(arguments[2],null);if(e.compute&&e.getOrientation)return e;if("string"==typeof e)h=d(arguments[0],{elementId:g,jsPlumbInstance:f});else if(b.isArray(e))if(b.isArray(e[0])||b.isString(e[0]))2===e.length&&b.isObject(e[1])?b.isString(e[0])?(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f},e[1]),h=d(e[0],c)):(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f,anchors:e[0]},e[1]),h=new a.jsPlumb.DynamicAnchor(c)):h=new o.DynamicAnchor({anchors:e,selector:null,elementId:g,jsPlumbInstance:f});else{var i={x:e[0],y:e[1],orientation:e.length>=4?[e[2],e[3]]:[0,0],offsets:e.length>=6?[e[4],e[5]]:[0,0],elementId:g,jsPlumbInstance:f,cssClass:7===e.length?e[6]:null};h=new a.jsPlumb.Anchor(i),h.clone=function(){return new a.jsPlumb.Anchor(i)}}return h.id||(h.id="anchor_"+F()),h},this.makeAnchors=function(c,d,e){for(var g=[],h=0,i=c.length;i>h;h++)"string"==typeof c[h]?g.push(a.jsPlumb.Anchors[c[h]]({elementId:d,jsPlumbInstance:e})):b.isArray(c[h])&&g.push(f.makeAnchor(c[h],d,e));return g},this.makeDynamicAnchor=function(b,c){return new a.jsPlumb.DynamicAnchor({anchors:b,selector:c,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={};var pa=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&a>=c.def.maxConnections},element:c.el,elementId:c.id,isSource:g,isTarget:h,addClass:function(a){f.addClass(c.el,a)},removeClass:function(a){f.removeClass(c.el,a)},onDrop:function(a){var b=a.endpoints[0];b.anchor.unlock()},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(a){return null!=a.suspendedElement&&null!=a.suspendedEndpoint&&a.suspendedEndpoint.element===c.el},getEndpoint:function(b){var e=c.def.endpoint;if(null==e||null==e._jsPlumb){var g=f.deriveEndpointAndAnchorSpec(b.getType().join(" "),!0),h=g.endpoints?a.jsPlumb.extend(d,{endpoint:c.def.def.endpoint||g.endpoints[1]}):d;g.anchors&&(h=a.jsPlumb.extend(h,{anchor:c.def.def.anchor||g.anchors[1]})),e=f.addEndpoint(c.el,h),e._mtNew=!0}if(d.uniqueEndpoint&&(c.def.endpoint=e),e.setDeleteOnEmpty(!0),b.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var i=f.getUIPosition(arguments,f.getZoom()),j=f.getOffset(c.el),k=f.getSize(c.el),l=null==i?[0,0]:e.anchor.positionFinder(i,j,k,e.anchor.constructorParams);e.anchor.x=l[0],e.anchor.y=l[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),l=a.jsPlumb.dragEvents.drop;return e.scope=e.scope||d.scope||f.Defaults.Scope,e[l]=b.wrap(e[l],k,!0),e.rank=d.rank||0,h&&(e[a.jsPlumb.dragEvents.over]=function(){return!0}),d.allowLoopback===!1&&(e.canDrop=function(a){var b=a.getDragElement()._jsPlumbRelatedElement;return b!==c.el}),f.initDroppable(c.el,e,"internal"),k};this.makeTarget=function(b,c,d){var e=a.jsPlumb.extend({_jsPlumb:this},d);a.jsPlumb.extend(e,c);for(var g=e.maxConnections||-1,h=function(b){var c=l(b),d=c.id,h=a.jsPlumb.extend({},e.dropOptions||{}),i=e.connectionType||"default";this.targetEndpointDefinitions[d]=this.targetEndpointDefinitions[d]||{},la(d),c.el._isJsPlumbGroup&&null==h.rank&&(h.rank=-1);var j={def:a.jsPlumb.extend({},e),uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};e.createEndpoint&&(j.uniqueEndpoint=!0,j.endpoint=f.addEndpoint(b,j.def),j.endpoint.setDeleteOnEmpty(!1)),c.def=j,this.targetEndpointDefinitions[d][i]=j,qa(c,e,h,e.isSource===!0,!0),c.el._katavorioDrop[c.el._katavorioDrop.length-1].targetDef=j}.bind(this),i=b.length&&b.constructor!==String?b:[b],j=0,k=i.length;k>j;j++)h(i[j]);return this},this.unmakeTarget=function(a,b){var c=l(a);return f.destroyDroppable(c.el,"internal"),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(c,d,e){var g=a.jsPlumb.extend({_jsPlumb:this},e);a.jsPlumb.extend(g,d);var h=g.connectionType||"default",i=f.deriveEndpointAndAnchorSpec(h);g.endpoint=g.endpoint||i.endpoints[0],g.anchor=g.anchor||i.anchors[0];for(var j=g.maxConnections||-1,m=g.onMaxConnections,n=function(d){var e=d.id,i=this.getElement(d.el);this.sourceEndpointDefinitions[e]=this.sourceEndpointDefinitions[e]||{},la(e);var l={def:a.jsPlumb.extend({},g),uniqueEndpoint:g.uniqueEndpoint,maxConnections:j,enabled:!0};g.createEndpoint&&(l.uniqueEndpoint=!0,l.endpoint=f.addEndpoint(c,l.def),l.endpoint.setDeleteOnEmpty(!1)),this.sourceEndpointDefinitions[e][h]=l,d.def=l;var n=a.jsPlumb.dragEvents.stop,o=a.jsPlumb.dragEvents.drag,p=a.jsPlumb.extend({},g.dragOptions||{}),q=p.drag,r=p.stop,s=null,t=!1;p.scope=p.scope||g.scope,p[o]=b.wrap(p[o],function(){q&&q.apply(this,arguments),t=!1}),p[n]=b.wrap(p[n],function(){if(r&&r.apply(this,arguments),this.currentlyDragging=!1,null!=s._jsPlumb){var a=g.anchor||this.Defaults.Anchor,b=s.anchor,c=s.connections[0],d=this.makeAnchor(a,e,this),h=s.element;if(null!=d.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+b.x*j[0],top:i.top+b.y*j[1]},l=d.positionFinder(k,i,j,d.constructorParams);d.x=l[0],d.y=l[1]}s.setAnchor(d,!0),s.repaint(),this.repaint(s.elementId),null!=c&&this.repaint(c.targetId)}}.bind(this));var u=function(c){if(3!==c.which&&2!==c.button){var l=this.sourceEndpointDefinitions[e][h];if(l.enabled){if(e=this.getId(this.getElement(d.el)),g.filter){var n=b.isString(g.filter)?pa(c,d.el,g.filter,this,g.filterExclude):g.filter(c,d.el);if(n===!1)return}var o=this.select({source:e}).length;if(l.maxConnections>=0&&o>=l.maxConnections)return m&&m({element:d.el,maxConnections:j},c),!1;var q=a.jsPlumb.getPositionOnElement(c,i,k),r={};a.jsPlumb.extend(r,g),r.isTemporarySource=!0,r.anchor=[q[0],q[1],0,0],r.dragOptions=p,l.def.scope&&(r.scope=l.def.scope),s=this.addEndpoint(e,r),t=!0,s.setDeleteOnEmpty(!0),l.uniqueEndpoint&&(l.endpoint?s.finalEndpoint=l.endpoint:(l.endpoint=s,s.setDeleteOnEmpty(!1)));var u=function(){f.off(s.canvas,"mouseup",u),f.off(d.el,"mouseup",u),t&&(t=!1,f.deleteEndpoint(s))};f.on(s.canvas,"mouseup",u),f.on(d.el,"mouseup",u);var v={};if(l.def.extract)for(var w in l.def.extract){var x=(c.srcElement||c.target).getAttribute(w);x&&(v[l.def.extract[w]]=x)}f.trigger(s.canvas,"mousedown",c,v),b.consume(c)}}}.bind(this);this.on(d.el,"mousedown",u),l.trigger=u,g.filter&&(b.isString(g.filter)||b.isFunction(g.filter))&&f.setDragFilter(d.el,g.filter);var v=a.jsPlumb.extend({},g.dropOptions||{});qa(d,g,v,!0,g.isTarget===!0)}.bind(this),o=c.length&&c.constructor!==String?c:[c],p=0,q=o.length;q>p;p++)n(l(o[p]));return this},this.unmakeSource=function(a,b,c){var d=l(a);f.destroyDroppable(d.el,"internal");var e=this.sourceEndpointDefinitions[d.id];if(e)for(var g in e)if(null==b||b===g){var h=e[g].trigger;h&&f.off(d.el,"mousedown",h),c||delete this.sourceEndpointDefinitions[d.id][g]}return this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,null,!0);return this.sourceEndpointDefinitions={},this};var ra=function(a,c,d){c=b.isArray(c)?c:[c];var e=T(a);d=d||"default";for(var f=0;fm;m++)i=l(c[m]),k[i.id]&&k[i.id][g]&&(h[m]=k[i.id][g].enabled,j=e?!h[m]:d,k[i.id][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}else{i=l(c);var o=i.id;k[o]&&k[o][g]&&(h=k[o][g].enabled,j=e?!h:d,k[o][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}return h}.bind(this),ua=function(a,c){return b.isString(a)||!a.length?c.apply(this,[a]):a.length?c.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a,b){return ta("source",a,null,!0,b),this.isSourceEnabled(a,b)},this.setSourceEnabled=function(a,b,c){return ta("source",a,b,null,c)},this.isSource=function(a,b){return b=b||"default",ua(a,function(a){var c=this.sourceEndpointDefinitions[l(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isSourceEnabled=function(a,b){return b=b||"default",ua(a,function(a){var c=this.sourceEndpointDefinitions[l(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a,b){return ta("target",a,null,!0,b),this.isTargetEnabled(a,b)},this.isTarget=function(a,b){return b=b||"default",ua(a,function(a){var c=this.targetEndpointDefinitions[l(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isTargetEnabled=function(a,b){return b=b||"default",ua(a,function(a){var c=this.targetEndpointDefinitions[l(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b,c){return ta("target",a,b,null,c)},this.ready=function(a){f.bind("ready",a)};var va=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return va(a,function(a){H(a,b,c)})},this.revalidate=function(a,b,c){return va(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b});var e=f.getDragManager();e&&e.updateOffsets(d),f.repaint(a)})},this.repaintEverything=function(){var a,b=c();for(a in u)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in u)H(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=l(a),i=u[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e],!1);if(delete u[h.id],b&&h.el&&3!==h.el.nodeType&&8!==h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var wa=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=f.getDragManager(),d=function(a){c&&c.elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),f.isSource(a.el)&&f.unmakeSource(a.el),f.isTarget(a.el)&&f.unmakeTarget(a.el),f.destroyDraggable(a.el),f.destroyDroppable(a.el),delete f.floatingConnections[a.id],delete w[a.id],delete x[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},e=1;e0;)d(e.el.childNodes[0]);b||wa(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(a){f.silently(function(){ka=!1,f.removeAllGroups(),f.removeGroupManager(),f.deleteEveryEndpoint(),a||f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},t.length=0,this.doReset&&this.doReset()}.bind(this))};var xa=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(xa),f.selectEndpoints().each(xa),u={},v={}},this.setDefaultScope=function(a){return D=a,f},this.deriveEndpointAndAnchorSpec=function(a,b){for(var c=((b?"":"default ")+a).split(/[\s]/),d=null,e=null,g=null,h=null,i=0;ih;h++)u[c][h].setElementId(c),u[c][h].setReferenceElement(a);delete u[e],this.sourceEndpointDefinitions[c]=this.sourceEndpointDefinitions[e],delete this.sourceEndpointDefinitions[e],this.targetEndpointDefinitions[c]=this.targetEndpointDefinitions[e],delete this.targetEndpointDefinitions[e],this.anchorManager.changeId(e,c);var j=this.getDragManager();j&&j.changeId(e,c),w[c]=w[e],delete w[e];var k=function(b,d,e){for(var f=0,g=b.length;g>f;f++)b[f].endpoints[d].setElementId(c),b[f].endpoints[d].setReferenceElement(a),b[f][e+"Id"]=c,b[f][e]=a};k(f,0,"source"),k(g,1,"target"),this.repaint(c)},this.setDebugLog=function(a){r=a},this.setSuspendDrawing=function(a,b){var c=B;return B=a,C=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return B},this.getSuspendedAt=function(){return C},this.batch=function(a,c){var d=this.isSuspendDrawing();d||this.setSuspendDrawing(!0);try{a()}catch(e){b.log("Function run while suspended failed",e)}d||this.setSuspendDrawing(!1,!c)},this.doWhileSuspended=this.batch,this.getCachedData=S,this.timestamp=c,this.show=function(a,b){return Q(a,"block",b),f},this.toggleVisible=R,this.addListener=this.bind;var ya=[];this.registerFloatingConnection=function(a,c,d){ya[a.id]=c,b.addToList(u,a.id,d)},this.getFloatingConnectionFor=function(a){return ya[a]}};b.extend(a.jsPlumbInstance,b.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(b,c){return this.getAttribute(a.jsPlumb.getElement(b),c)},convertToFullOverlaySpec:function(a){return b.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||b.uuid(),a},registerConnectionType:function(b,c){if(this._connectionTypes[b]=a.jsPlumb.extend({},c),c.overlays){for(var d={},e=0;ea;a++)this.removeOverlay(arguments[a])},moveParent:function(a){if(this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas&&this.canvas.parentNode){this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor===String||a.constructor===Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor===String||a.constructor===Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null},_clazzManip:function(a,b,c){if(!c)for(var d in this._jsPlumb.overlays)this._jsPlumb.overlays[d][a+"Class"](b)},addClass:function(a,b){this._clazzManip("add",a,b)},removeClass:function(a,b){this._clazzManip("remove",a,b)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,b,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;if(b.element){var e=c.getUIPosition(arguments,c.getZoom());null!=e&&c.setPosition(b.element,e),c.repaint(b.element,e),a.paint({anchorPoint:a.anchor.getCurrentLocation({element:a})})}},stopDrag:function(){d=!0}}},e=function(a,b,c,d){var e=b.createElement("div",{position:"absolute"});b.appendElement(e);var f=b.getId(e);b.setPosition(e,c),e.style.width=d[0]+"px",e.style.height=d[1]+"px",b.manage(f,e,!0),a.id=f,a.element=e},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?this.connections.indexOf(a):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)),!c&&m&&0===this.connections.length&&i.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:c!==!0})},this.deleteEveryConnection=function(a){for(var b=this.connections.length,c=0;b>c;c++)i.deleteConnection(this.connections[0],a)},this.detachFrom=function(a,b,c){for(var d=[],e=0;ef;f++)i.deleteConnection(d[0]);return this},this.getElement=function(){return this.element},this.setElement=function(d){var e=this._jsPlumb.instance.getId(d),f=this.elementId;return c.removeWithFunction(a.endpointsByElement[this.elementId],function(a){return a.id===this.id}.bind(this)),this.element=b.getElement(d),this.elementId=i.getId(this.element),i.anchorManager.rehomeEndpoint(this,f,this.element),i.dragManager.endpointAdded(this.element),c.addToList(a.endpointsByElement,e,this),this},this.makeInPlaceCopy=function(){var b=this.anchor.getCurrentLocation({element:this}),c=this.anchor.getOrientation(this),d=this.anchor.getCssClass(),e={bind:function(){},compute:function(){return[b[0],b[1]]},getCurrentLocation:function(){return[b[0],b[1]]},getOrientation:function(){return c},getCssClass:function(){return d}};return k({dropOptions:a.dropOptions,anchor:e,source:this.element,paintStyle:this.getPaintStyle(),endpoint:a.hideOnDrag?"Blank":this.endpoint,_transient:!0,scope:this.scope,reference:this})},this.connectorSelector=function(){return this.connections[0]},this.setStyle=this.setPaintStyle,this.paint=function(a){a=a||{};var b=a.timestamp,c=!(a.recalc===!1);if(!b||this.timestamp!==b){var d=i.updateOffset({elId:this.elementId,timestamp:b}),e=a.offset?a.offset.o:d.o;if(null!=e){var f=a.anchorPoint,g=a.connectorPaintStyle;if(null==f){var j=a.dimensions||d.s,k={xy:[e.left,e.top],wh:j,element:this,timestamp:b};if(c&&this.anchor.isDynamic&&this.connections.length>0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]===this?1:0,n=0===m?l.sourceId:l.targetId,o=i.getCachedData(n),p=o.o,q=o.s;k.index=0===m?1:0,k.connection=l,k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}else this.connections.length>0&&(k.connection=this.connections[0]);f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse), -s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(){if(!p&&b.isDragSupported(this.element)){var g,h={id:null,element:null},m=null,n=!1,o=null,q=d(this,h,i),r=a.dragOptions||{},s={},t=b.dragEvents.start,u=b.dragEvents.stop,v=b.dragEvents.drag,w=b.dragEvents.beforeStart,x=function(a){g=a.e.payload||{}},y=function(c){m=this.connectorSelector();var d=!0;this.isEnabled()||(d=!1),null!=m||this.isSource||this.isTemporarySource||(d=!1),!this.isSource||!this.isFull()||null!=m&&this.dragAllowedWhenFull||(d=!1),null==m||m.isDetachable(this)||(this.isFull()?d=!1:m=null);var l=i.checkCondition(null==m?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:m});if(l===!1?d=!1:"object"==typeof l?b.extend(l,g||{}):l=g||{},d===!1)return i.stopDrag&&i.stopDrag(this.canvas),q.stopDrag(),!1;for(var p=0;p0&&this.connectionsDetachable!==!1}.bind(this),i.initDraggable(this.canvas,r,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:i.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,this.initDraggable();var t=function(d,e,f,g){if(b.isDropSupported(this.element)){var h=a.dropOptions||i.Defaults.DropOptions||b.Defaults.DropOptions;h=b.extend({},h),h.scope=h.scope||this.scope;var j=b.dragEvents.drop,k=b.dragEvents.over,l=b.dragEvents.out,m=this,n=i.EndpointDropHandler({getEndpoint:function(){return m},jsPlumb:i,enabled:function(){return null!=f?f.isEnabled():!0},isFull:function(){return f.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){m.addClass(a)},removeClass:function(a){m.removeClass(a)},isDropAllowed:function(){return m.isDropAllowed.apply(m,arguments)},reference:g,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});h[j]=c.wrap(h[j],n,!0),h[k]=c.wrap(h[k],function(){var a=b.getDragObject(arguments),c=i.getAttribute(b.getElement(a),"dragId"),d=i.getFloatingConnectionFor(c);if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;if(f){var g=i.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](i.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](i.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),h[l]=c.wrap(h[l],function(){var a=b.getDragObject(arguments),c=null==a?null:i.getAttribute(b.getElement(a),"dragId"),d=c?i.getFloatingConnectionFor(c):null;if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;f&&(this.removeClass(i.endpointDropAllowedClass),this.removeClass(i.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),i.initDroppable(d,h,"internal",e)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;dc[0][0],d===!1?-1:1}},n=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:-1},o={top:function(a,b){return a[0]>b[0]?1:-1},right:m(!0),bottom:m(!0),left:n},p=function(a,b){return a.sort(b)},q=function(a,b){var c=j.getCachedData(a),d=c.s,g=c.o,h=function(b,c,d,g,h,i,j){if(g.length>0)for(var k=p(g,o[b]),m="right"===b||"top"===b,n=l(b,c,d,k,h,i,m),q=function(a,b){e[a.id]=[b[0],b[1],b[2],b[3]],f[a.id]=j},r=0;r-1&&(g[d].splice(i,1),b.addToList(g,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor===c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e,f){if(a!==d){e.sourceId=d,e.source=f,b.removeWithFunction(g[a],function(a){return a[0].id===e.id});var h=b.findWithFunction(g[e.targetId],function(a){return a[0].id===e.id});h>-1&&(g[e.targetId][h][0]=e,g[e.targetId][h][1]=e.endpoints[0],g[e.targetId][h][2]=e.endpoints[0].anchor.constructor===c.DynamicAnchor),b.addToList(g,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor===c.DynamicAnchor]),e.endpoints[1].anchor.isContinuous&&(e.source===e.target?e._jsPlumb.instance.removeElement(e.endpoints[1].canvas):null==e.endpoints[1].canvas.parentNode&&e._jsPlumb.instance.appendElement(e.endpoints[1].canvas)),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,b,c){var e=d[b]||[],f=j.getId(c);if(f!==b){var g=e.indexOf(a);if(g>-1){var i=e.splice(g,1)[0];h.add(i,f)}}for(var k=0;kb.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;q0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.isLocked()||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!==f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.setAnchor=function(a){e=a},this.getCssClass=function(){return e&&e.getCssClass()||""},this.setAnchorCoordinates=function(a){var b=jsPlumbUtil.findWithFunction(this.anchors,function(b){return b.x===a[0]&&b.y===a[1]});return-1!==b?(this.setAnchor(this.anchors[b]),!0):!1}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor===String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),a.jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(a){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)b?a>=b&&c>=a:b>=a&&a>=c},o=n;this.lineIntersection=function(a,b,c,f){var k=Math.abs(d.gradient({x:a,y:b},{x:c,y:f})),l=Math.abs(e),m=l===1/0?g:i-l*g,n=[],p=k===1/0?a:b-k*a;if(k!==l)if(k===1/0&&0===l)o(a,g,h)&&o(i,b,f)&&(n=[a,i]);else if(0===k&&l===1/0)o(b,i,j)&&o(g,a,c)&&(n=[g,b]);else{var q,r;k===1/0?(q=a,o(q,g,h)&&(r=l*a+m,o(r,b,f)&&(n=[q,r]))):0===k?(r=b,o(r,i,j)&&(q=(b-m)/l,o(q,a,c)&&(n=[q,r]))):(q=(p-m)/(l-k),r=l*q+m,o(q,g,h)&&o(r,i,j)&&(n=[q,r]))}return n},this.boxIntersection=function(a,b,c,d){var e=[];return e.push.apply(e,this.lineIntersection(a,b,a+c,b)),e.push.apply(e,this.lineIntersection(a+c,b,a+c,b+d)),e.push.apply(e,this.lineIntersection(a+c,b+d,a,b+d)),e.push.apply(e,this.lineIntersection(a,b+d,a,b)),e},this.boundingBoxIntersection=function(a){return this.boxIntersection(a.x,a.y,a.w,a.h)}},Arc:function(a){var c=(b.Segments.AbstractSegment.apply(this,arguments),function(b,c){return d.theta([a.cx,a.cy],[b,c])}),e=function(a,b){if(a.anticlockwise){var c=a.startAnglea-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1===b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||f!==1/0&&f!==-(1/0)||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=c/h*2*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}];b.Segments.AbstractSegment.apply(this,arguments);this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds},this.findClosestPointOnPath=function(b,c){var d=a.jsBezier.nearestPointOnCurve({x:b,y:c},this.curve);return{d:Math.sqrt(Math.pow(d.point.x-b,2)+Math.pow(d.point.y-c,2)),x:d.point.x,y:d.point.y,l:d.location,s:this}},this.lineIntersection=function(b,c,d,e){return a.jsBezier.lineIntersection(b,c,d,e,this.curve)}}},b.SegmentRenderer={getPath:function(a,b){return{Straight:function(b){var c=a.getCoordinates();return(b?"M "+c.x1+" "+c.y1+" ":"")+"L "+c.x2+" "+c.y2},Bezier:function(b){var c=a.params;return(b?"M "+c.x2+" "+c.y2+" ":"")+"C "+c.cp2x+" "+c.cp2y+" "+c.cp1x+" "+c.cp1y+" "+c.x1+" "+c.y1},Arc:function(b){var c=a.params,d=a.sweep>Math.PI?1:0,e=a.anticlockwise?0:1;return(b?"M"+a.x1+" "+a.y1+" ":"")+"A "+a.radius+" "+c.r+" 0 "+d+","+e+" "+a.x2+" "+a.y2}}[a.type](b)}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-(1/0),maxY:-(1/0)}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=null;this.getPathData=function(){for(var a="",c=0;c0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1===a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},t=function(a,c,d){if(d.x1!==d.x2||d.y1!==d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},u=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1===w,perpendicular:0===w,orthogonal:1===w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v],stubs:[k,l]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x};this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)};return this.pointOnPath=function(a,b){var c=s(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=s(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=s(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q=v.call(this,a),u(),this._compute(q,a),this.x=q.points[0],this.y=q.points[1],this.w=q.points[2],this.h=q.points[3],this.segment=q.segment,r()},{addSegment:t,prepareCompute:v,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(a,b,c,d){var e=this._compute.apply(this,arguments);return this.x=e[0],this.y=e[1],this.w=e[2],this.h=e[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,e};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c,d){this.radius=c.radius||this.radius;var e=a[0]-this.radius,f=a[1]-this.radius,g=2*this.radius,h=2*this.radius;if(c.stroke){var i=c.strokeWidth||1;e-=i,f-=i,g+=2*i,h+=2*i}return[e,f,g,h,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c,d){var e=c.width||this.width,f=c.height||this.height,g=a[0]-e/2,h=a[1]-f/2;return[g,h,e,f]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var f=function(a){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(f,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",f.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,g=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor===String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(g,e),this._compute=function(a,b,c,d){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=b.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(a,b,d){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var e=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,f=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,e,f,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[f,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments);this.type="Blank",f.apply(this,arguments),this._compute=function(a,b,c,d){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=b.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(a,b){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,f],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments);var c=this;a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,d,e){var f=d.width||c.width,g=d.height||c.height,h=a[0]-f/2,i=a[1]-g/2;return[h,i,f,g]}};var g=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation,this.visible=a.visible!==!1};g.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(a,b){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",g.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{};var e=this;this.length=a.length||20,this.width=a.width||20,this.id=a.id;var f=(a.direction||1)<0?-1:1,h=a.paintStyle||{"stroke-width":1},i=a.foldback||.623;this.computeMaxSize=function(){return 1.5*e.width},this.elementCreated=function(c,d){if(this.path=c,a.events)for(var e in a.events)b.on(c,e,a.events[e])},this.draw=function(a,b){var e,g,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;e=a.pointAlongPathFrom(n,m,!1),g=a.pointAlongPathFrom(n,m-f*this.length/2,!1),j=d.pointOnLine(e,g,this.length)}else if(1===this.loc){if(e=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(e,g,this.length),-1===f){var o=j;j=e,e=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,this.length),e=d.pointOnLine(j,g,this.length),-1===f){var p=j;j=e,e=p}}else e=a.pointAlongPathFrom(this.loc,f*this.length/2),g=a.pointOnPath(this.loc),j=d.pointOnLine(e,g,this.length);k=d.perpendicularLineTo(e,j,this.width),l=d.pointOnLine(e,j,i*this.length);var q={hxy:e,tail:k,cxy:l},r=h.stroke||b.stroke,s=h.fill||b.stroke,t=h.strokeWidth||b.strokeWidth;return{component:a,d:q,"stroke-width":t,stroke:r,fill:s,minX:Math.min(e.x,k[0].x,k[1].x),maxX:Math.max(e.x,k[0].x,k[1].x),minY:Math.min(e.y,k[0].y,k[1].y),maxY:Math.max(e.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,g,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback},cleanup:function(){this.path&&this.canvas&&this.canvas.removeChild(this.path)}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=b.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var h=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},i=function(a){b.jsPlumbUIComponent.apply(this,arguments),g.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var c=this._jsPlumb.div=b.getElement(this._jsPlumb.create(this._jsPlumb.component));c.style.position="absolute",jsPlumb.addClass(c,this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:"")),this._jsPlumb.instance.appendElement(c),this._jsPlumb.instance.getId(c),this.canvas=c;var d="translate(-50%, -50%)";c.style.webkitTransform=d,c.style.mozTransform=d,c.style.msTransform=d,c.style.oTransform=d,c.style.transform=d,c._jsPlumb=this,a.visible===!1&&(c.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=h(this);if(null!=e&&2===e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,i=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),i=!0),f=a.pointOnPath(g,i)}else{var j=this.loc.constructor===Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(i,[b.jsPlumbUIComponent,g],{getDimensions:function(){return[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(h(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a,b){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div), -this.detached=!1},computeMaxSize:function(){var a=h(this);return Math.max(a[0],a[1])},paint:function(a,b){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(a){this.type="Custom",i.apply(this,arguments)},c.extend(b.Overlays.Custom,i),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.strokeWidth=5,this.type="GuideLines",g.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b,c){var e=b.pointAlongPathFrom(a.loc,a.length/2),f=b.pointOnPath(a.loc),g=d.pointOnLine(e,f,a.length),h=d.perpendicularLineTo(e,g,40),i=d.perpendicularLineTo(g,e,20);return{connector:b,head:e,tail:g,headLine:i,tailLine:h,minX:Math.min(e.x,g.x,i[0].x,i[1].x),minY:Math.min(e.y,g.y,i[0].y,i[1].y),maxX:Math.max(e.x,g.x,i[0].x,i[1].x),maxY:Math.max(e.y,g.y,i[0].y,i[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle;this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return b.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fill&&(d.style.background=this.labelStyle.fill),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),i.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
"))},updateFrom:function(a){null!=a.label&&this.setLabel(a.label)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumbUtil,c=a.jsPlumbInstance,d="jtk-group-collapsed",e="jtk-group-expanded",f="[jtk-group-content]",g="elementDraggable",h="stop",i="revert",j="_groupManager",k="_jsPlumbGroup",l="_jsPlumbGroupDrag",m="group:addMember",n="group:removeMember",o="group:add",p="group:remove",q="group:expand",r="group:collapse",s="groupDragStop",t="connectionMoved",u="internal.connectionDetached",v="removeAll",w="orphanAll",x="show",y="hide",z=function(a){function c(a){delete a.proxies;var c,d=i[a.id];null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete i[a.id]),d=j[a.id],null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete j[a.id])}function f(b,c){for(var d=b.getMembers(),e=0;e0&&h0&&j0?a[0]:u},w=d.ghost===!0,x=w||d.constrain===!0,y=d.revert!==!1,z=d.orphan===!0,A=d.prune===!0,B=d.dropOverride===!0,C=d.proxied!==!1,D=[];if(this.connections={source:[],target:[],internal:[]},this.getAnchor=function(a,b){return d.anchor||"Continuous"},this.getEndpoint=function(a,b){return d.endpoint||["Dot",{radius:10}]},this.collapsed=!1,d.draggable!==!1){var E={stop:function(a){c.fire(s,jsPlumb.extend(a,{group:t}))},scope:l};d.dragOptions&&a.jsPlumb.extend(E,d.dragOptions),c.draggable(d.el,E)}d.droppable!==!1&&c.droppable(d.el,{drop:function(a){var b=a.drag.el;if(!b._isJsPlumbGroup){var d=b._jsPlumbGroup;if(d!==t){if(null!=d&&d.overrideDrop(b,t))return;c.getGroupManager().addToGroup(t,b,!1)}}}});var F=function(a,b){for(var c=null==a.nodeType?a:[a],d=0;dd;d++){var f=D[0];t.remove(f,a,b,!0),c.remove(f,!0)}D.length=0,c.getGroupManager().updateConnectionsForGroup(t)},this.orphanAll=function(){for(var a={},b=0;ba?-1:0===a?0:1}),n=function(a){return[m(a[2]-a[0]),m(a[3]-a[1])]},o=function(a,b,c,d){if(j!==b||k!==c){var e=null==j?d.sx:j,f=null==k?d.sy:k,g=e===b?"v":"h";j=b,k=c,a.push([e,f,b,c,g])}},p=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},q=function(a){var b=[];return b.push.apply(b,a),b},r=function(a,b,c){for(var f,h,i,j=null,k=0;k0&&j[4]!==f[4]){var m=Math.min(p(j),p(f)),o=Math.min(l,m/2);j[2]-=h[0]*o,j[3]-=h[1]*o,f[0]+=i[0]*o,f[1]+=i[1]*o;var r=h[1]===i[0]&&1===i[0]||h[1]===i[0]&&0===i[0]&&h[0]!==i[1]||h[1]===i[0]&&-1===i[0],s=f[1]>j[3]?1:-1,t=f[0]>j[2]?1:-1,u=s===t,v=u&&r||!u&&!r?f[0]:j[2],w=u&&r||!u&&!r?j[3]:f[1];g.addSegment(a,d,{x1:j[0],y1:j[1],x2:j[2],y2:j[3]}),g.addSegment(a,e,{r:o,x1:j[2],y1:j[3],x2:f[0],y2:f[1],cx:v,cy:w,ac:r})}else{var x=j[2]===j[0]?0:j[2]>j[0]?c.lw/2:-(c.lw/2),y=j[3]===j[1]?0:j[3]>j[1]?c.lw/2:-(c.lw/2);g.addSegment(a,d,{x1:j[0]-x,y1:j[1]-y,x2:j[2]+x,y2:j[3]+y})}j=f}null!=f&&g.addSegment(a,d,{x1:f[0],y1:f[1],x2:f[2],y2:f[3]})};this._compute=function(a,b){c=[],j=null,k=null,f=null;var d=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},e={perpendicular:d,orthogonal:d,opposite:function(b){var c=a,d="x"===b?0:1,e={x:function(){return 1===c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1===c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1===c.so[d]&&(c.startStubYj[b][0],p=e[b][m][0],q=e[b][m][1],r=d[b][m][n];return c.segment===r[3]||c.segment===r[2]&&o?f[b]:c.segment===r[2]&&p>q?g[b]:c.segment===r[2]&&q>=p||c.segment===r[1]&&!o?i[b]:c.segment===r[0]||c.segment===r[1]&&o?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1===g.so[0]?Math.min(c,e):Math.max(c,e),y:-1===g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,e,f){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],k=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var l=e+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+g.maxStub;return{x:[[d,l],[f,l]],y:[[l,d],[l,f]]}[c]}return!k||1===h.so[m]&&d>f||-1===h.so[m]&&f>d?{x:[[d,v],[f,v]],y:[[u,d],[u,f]]}[c]:1===h.so[m]&&f>d||-1===h.so[m]&&d>f?{x:[[u,h.sy],[u,h.ty]],y:[[h.sx,v],[h.tx,v]]}[c]:void 0}},y=x[a.anchorOrientation](a.sourceAxis,p,q,s,t);if(y)for(var z=0;z=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0},f=function(a){a=a||{},this.type="StateMachine";var c,f=b.Connectors.AbstractBezierConnector.apply(this,arguments),g=a.curviness||10,h=a.margin||5,i=a.proximityLimit||80;a.orientation&&"clockwise"===a.orientation;this._computeBezier=function(a,b,j,k,l,m){var n=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=b.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var c=this,d=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(d,e,f){var g=c.getSegments(),h="",i=[0,0];if(f.xmin<0&&(i[0]=-f.xmin),f.ymin<0&&(i[1]=-f.ymin),g.length>0){h=c.getPathData();var j={d:h,transform:"translate("+i[0]+","+i[1]+")","pointer-events":a["pointer-events"]||"visibleStroke"},k=null,l=[c.x,c.y,c.w,c.h];if(d.outlineStroke){var m=d.outlineWidth||1,n=d.strokeWidth+2*m;k=b.extend({},d),delete k.gradient,k.stroke=d.outlineStroke,k.strokeWidth=n,null==c.bgPath?(c.bgPath=t("path",j),b.addClass(c.bgPath,b.connectorOutlineClass),y(c.svg,c.bgPath,0)):s(c.bgPath,j),x(c.svg,c.bgPath,k,l,c)}null==c.path?(c.path=t("path",j),y(c.svg,c.path,d.outlineStroke?1:0)):s(c.path,j),x(c.svg,c.path,d,l,c)}}},c.extend(b.ConnectorRenderers.svg,z);var A=b.SvgEndpoint=function(a){var c=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);c.renderer.paint=function(a){var c=b.extend({},a);c.outlineStroke&&(c.stroke=c.outlineStroke),null==this.node?(this.node=this.makeNode(c),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,c,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1;this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.elementCreated&&this.elementCreated(this.path,a.component),this.canvas=a.component.svg);var e=c&&1===c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.stroke?a.stroke:null,fill:a.fill?a.fill:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(a,b){this.path&&b.canvas&&b.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]),b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=a.Katavorio,e=a.Biltong,f=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c},g=function(a,c){c=c||"main";var f="_katavorio_"+c,g=a[f],h=a.getEventManager();return g||(g=new d({bind:h.on,unbind:h.off,getSize:b.getSize,getConstrainingRectangle:function(a){return[a.parentNode.scrollWidth,a.parentNode.scrollHeight]},getPosition:function(b,c){var d=a.getOffset(b,c,b._katavorioDrag?b.offsetParent:null);return[d.left,d.top]},setPosition:function(a,b){a.style.left=b[0]+"px",a.style.top=b[1]+"px"},addClass:b.addClass,removeClass:b.removeClass,intersects:e.intersects,indexOf:function(a,b){return a.indexOf(b)},scope:a.getDefaultScope(),css:{noSelect:a.dragSelectClass,droppable:"jtk-droppable",draggable:"jtk-draggable",drag:"jtk-drag",selected:"jtk-drag-selected",active:"jtk-drag-active",hover:"jtk-drag-hover",ghostProxy:"jtk-ghost-proxy"}}),g.setZoom(a.getZoom()),a[f]=g,a.bind("zoom",g.setZoom)),g},h=function(a){var b=a.el._jsPlumbDragOptions,c=!0;return b.canDrag&&(c=b.canDrag()),c&&(this.setHoverSuspended(!0),this.select({source:a.el}).addClass(this.elementDraggingClass+" "+this.sourceElementDraggingClass,!0),this.select({target:a.el}).addClass(this.elementDraggingClass+" "+this.targetElementDraggingClass,!0),this.setConnectionBeingDragged(!0)),c},i=function(a){var b=this.getUIPosition(arguments,this.getZoom());if(null!=b){var c=a.el._jsPlumbDragOptions;this.draw(a.el,b,null,!0),c._dragging&&this.addClass(a.el,"jtk-dragged"),c._dragging=!0}},j=function(a){for(var b,c=a.selection,d=function(a){null!=a[1]&&(b=this.getUIPosition([{el:a[2].el,pos:[a[1].left,a[1].top]}]),this.draw(a[2].el,b)),delete a[0]._jsPlumbDragOptions._dragging,this.removeClass(a[0],"jtk-dragged"),this.select({source:a[2].el}).removeClass(this.elementDraggingClass+" "+this.sourceElementDraggingClass,!0),this.select({target:a[2].el}).removeClass(this.elementDraggingClass+" "+this.targetElementDraggingClass,!0), -this.getDragManager().dragEnded(a[2].el)}.bind(this),e=0;e0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},r=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h,i=a.getId(g);b[i]||(b[i]=g,c.push(g),d[i]={});var j=function(b){if(b)for(var c=0;c0){h||(h=a.getOffset(g));var m=a.getOffset(k);d[i][l]={id:l,offset:{left:m.left-h.left,top:m.top-h.top}},f[l]=i}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b,c){if(null!=b){c=c||{};var e,g=jsPlumb.getElement(b),h=a.getId(g),i=d[h];if(i)for(var j in i)if(i.hasOwnProperty(j)){var k=jsPlumb.getElement(j),l=c[j]||a.getOffset(k);if(null==k.offsetParent&&null!=d[h][j])continue;e||(e=a.getOffset(g)),d[h][j]={id:j,offset:{left:l.left-e.left,top:l.top-e.top}},f[j]=h}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!==h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){if(null!=b.offsetParent){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)}},this.setParent=function(b,c,e,g,h){var i=f[c];d[g]||(d[g]={});var j=a.getOffset(e),k=h||a.getOffset(b);i&&d[i]&&delete d[i][c],d[g][c]={id:c,offset:{left:k.left-j.left,top:k.top-j.top}},f[c]=g},this.clearParent=function(a,b){var c=f[b];c&&(delete d[c][b],delete f[b])},this.revalidateParent=function(b,c,d){var e=f[c];if(e){var g={};g[c]=d,this.updateOffsets(e,g),a.revalidate(e)}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},s=function(a,b,d){b=c.fastTrim(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b;try{var e=a.classList;if(null!=e){for(;e.length>0;)e.remove(e.item(0));for(var f=0;f0||a.scrollLeft>0)&&(d.left-=a.scrollLeft,d.top-=a.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent===c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!==g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight},getRenderMode:function(){return"svg"},draggable:function(a,b){var d;return a=c.isArray(a)||null!=a.length&&!c.isString(a)?a:[a],Array.prototype.slice.call(a).forEach(function(a){d=this.info(a),d.el&&this._initDraggableIfNecessary(d.el,!0,b,d.id,!0)}.bind(this)),this},initDraggable:function(a,b,c){g(this,c).draggable(a,b),a._jsPlumbDragOptions=b},destroyDraggable:function(a,b){g(this,b).destroyDraggable(a),delete a._jsPlumbDragOptions},unbindDraggable:function(a,b,c,d){g(this,d).destroyDraggable(a,b,c)},setDraggable:function(a,b){return jsPlumb.each(a,function(a){this.isDragSupported(a)&&(this._draggableStates[this.getAttribute(a,"id")]=b,this.setElementDraggable(a,b))}.bind(this))},_draggableStates:{},toggleDraggable:function(a){var b;return jsPlumb.each(a,function(a){var c=this.getAttribute(a,"id");return b=null==this._draggableStates[c]?!1:this._draggableStates[c],b=!b,this._draggableStates[c]=b,this.setDraggable(a,b),b}.bind(this)),b},_initDraggableIfNecessary:function(a,b,d,e,f){if(!jsPlumb.headless){var g=null==b?!1:b;if(g&&jsPlumb.isDragSupported(a,this)){var k=d||this.Defaults.DragOptions;if(k=jsPlumb.extend({},k),jsPlumb.isAlreadyDraggable(a,this))d.force&&this.initDraggable(a,k);else{var l=jsPlumb.dragEvents.drag,m=jsPlumb.dragEvents.stop,n=jsPlumb.dragEvents.start;this.manage(e,a),k[n]=c.wrap(k[n],h.bind(this)),k[l]=c.wrap(k[l],i.bind(this)),k[m]=c.wrap(k[m],j.bind(this));var o=this.getId(a);this._draggableStates[o]=!0;var p=this._draggableStates[o];k.disabled=null==p?!1:!p,this.initDraggable(a,k),this.getDragManager().register(a),f&&this.fire("elementDraggable",{el:a,options:k})}}}},animationSupported:!0,getElement:function(a){return null==a?null:(a="string"==typeof a?a:null!=a.length&&null==a.enctype?a[0]:a,"string"==typeof a?document.getElementById(a):a)},removeElement:function(a){g(this).elementRemoved(a),this.getEventManager().remove(a)},doAnimate:function(a,c,d){d=d||{};var e=this.getOffset(a),f=k(e,c),g=f[0]-e.left,h=f[1]-e.top,i=d.duration||250,j=15,l=i/j,m=j/i*g,n=j/i*h,o=0,p=setInterval(function(){b.setPosition(a,{left:e.left+m*(o+1),top:e.top+n*(o+1)}),null!=d.step&&d.step(o,Math.ceil(l)),o++,o>=l&&(window.clearInterval(p),null!=d.complete&&d.complete())},j)},destroyDroppable:function(a,b){g(this,b).destroyDroppable(a)},unbindDroppable:function(a,b,c,d){g(this,d).destroyDroppable(a,b,c)},droppable:function(a,b){a=c.isArray(a)||null!=a.length&&!c.isString(a)?a:[a];var d;return b=b||{},b.allowLoopback=!1,Array.prototype.slice.call(a).forEach(function(a){d=this.info(a),d.el&&this.initDroppable(d.el,b)}.bind(this)),this},initDroppable:function(a,b,c){g(this,c).droppable(a,b)},isAlreadyDraggable:function(a){return null!=a._katavorioDrag},isDragSupported:function(a,b){return!0},isDropSupported:function(a,b){return!0},isElementDraggable:function(a){return a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.isEnabled()},getDragObject:function(a){return a[0].drag.getDragElement()},getDragScope:function(a){return a._katavorioDrag&&a._katavorioDrag.scopes.join(" ")||""},getDropEvent:function(a){return a[0].e},getUIPosition:function(a,b){var c=a[0].el;if(null==c.offsetParent)return null;var d=a[0].finalPos||a[0].pos,e={left:d[0],top:d[1]};if(c._katavorioDrag&&c.offsetParent!==this.getContainer()){var f=this.getOffset(c.offsetParent);e.left+=f.left,e.top+=f.top}return e},setDragFilter:function(a,b,c){a._katavorioDrag&&a._katavorioDrag.setFilter(b,c)},setElementDraggable:function(a,c){a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.setEnabled(c)},setDragScope:function(a,b){a._katavorioDrag&&a._katavorioDrag.k.setDragScope(a,b)},setDropScope:function(a,b){a._katavorioDrop&&a._katavorioDrop.length>0&&a._katavorioDrop[0].k.setDropScope(a,b)},addToPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.addToPosse.apply(e,a)})},setPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.setPosse.apply(e,a)})},removeFromPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.removeFromPosse.apply(e,a)})},removeFromAllPosses:function(a){var c=g(this);b.each(a,function(a){c.removeFromAllPosses(b.getElement(a))})},setPosseState:function(a,c,d){var e=g(this);b.each(a,function(a){e.setPosseState(b.getElement(a),c,d)})},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete",beforeStart:"beforeStart"},animEvents:{step:"step",complete:"complete"},stopDrag:function(a){a._katavorioDrag&&a._katavorioDrag.abort()},addToDragSelection:function(a){g(this).select(a)},removeFromDragSelection:function(a){g(this).deselect(a)},clearDragSelection:function(){g(this).deselectAll()},trigger:function(a,b,c,d){this.getEventManager().trigger(a,b,c,d)},doReset:function(){for(var a in this)0===a.indexOf("_katavorio_")&&this[a].reset()},getEventManager:function(){return f(this)},on:function(a,b,c){return this.getEventManager().on.apply(this,arguments),this},off:function(a,b,c){return this.getEventManager().off.apply(this,arguments),this}});var v=function(a){var b=function(){/complete|loaded|interactive/.test(document.readyState)&&"undefined"!=typeof document.body&&null!=document.body?a():setTimeout(b,9)};b()};v(b.init)}.call("undefined"!=typeof window?window:this); +(function(){function a(a,b){return[-a[0][b]+3*a[1][b]+-3*a[2][b]+a[3][b],3*a[0][b]-6*a[1][b]+3*a[2][b],-3*a[0][b]+3*a[1][b],a[0][b]]}function b(b){return[a(b,"x"),a(b,"y")]}function c(a){return 0>a?-1:a>0?1:0}function d(a,b,d,e){var f,g,h=b/a,i=d/a,j=e/a,k=(3*i-Math.pow(h,2))/9,l=(9*h*i-27*j-2*Math.pow(h,3))/54,m=Math.pow(k,3)+Math.pow(l,2),n=[];if(m>=0)f=c(l+Math.sqrt(m))*Math.pow(Math.abs(l+Math.sqrt(m)),1/3),g=c(l-Math.sqrt(m))*Math.pow(Math.abs(l-Math.sqrt(m)),1/3),n[0]=-h/3+(f+g),n[1]=-h/3-(f+g)/2,n[2]=-h/3-(f+g)/2,0!==Math.abs(Math.sqrt(3)*(f-g)/2)&&(n[1]=-1,n[2]=-1);else{var o=Math.acos(l/Math.sqrt(-Math.pow(k,3)));n[0]=2*Math.sqrt(-k)*Math.cos(o/3)-h/3,n[1]=2*Math.sqrt(-k)*Math.cos((o+2*Math.PI)/3)-h/3,n[2]=2*Math.sqrt(-k)*Math.cos((o+4*Math.PI)/3)-h/3}for(var p=0;3>p;p++)(n[p]<0||n[p]>1)&&(n[p]=-1);return n}"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var e={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},f=64,g=Math.pow(2,-f-1),h=function(a,b){for(var c=[],d=j(a,b),f=b.length-1,g=2*f-1,h=k(d,g,c,0),i=e.subtract(a,b[0]),l=e.square(i),m=0,n=0;h>n;n++){i=e.subtract(a,o(b,f,c[n],null,null));var p=e.square(i);l>p&&(l=p,m=c[n])}return i=e.subtract(a,b[f]),p=e.square(i),l>p&&(l=p,m=1),{location:m,distance:l}},i=function(a,b){var c=h(a,b);return{point:o(b,b.length-1,c.location,null,null),location:c.location}},j=function(a,b){for(var c=b.length-1,d=2*c-1,f=[],g=[],h=[],i=[],j=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],k=0;c>=k;k++)f[k]=e.subtract(b[k],a);for(var k=0;c-1>=k;k++)g[k]=e.subtract(b[k+1],b[k]),g[k]=e.scale(g[k],3);for(var l=0;c-1>=l;l++)for(var m=0;c>=m;m++)h[l]||(h[l]=[]),h[l][m]=e.dotProduct(g[l],f[m]);for(k=0;d>=k;k++)i[k]||(i[k]=[]),i[k].y=0,i[k].x=parseFloat(k)/d;for(var n=c,o=c-1,p=0;n+o>=p;p++){var q=Math.max(0,p-o),r=Math.min(p,n);for(k=q;r>=k;k++){var s=p-k;i[k+s].y+=h[s][k]*j[s][k]}}return i},k=function(a,b,c,d){var e,g,h=[],i=[],j=[],p=[];switch(l(a,b)){case 0:return 0;case 1:if(d>=f)return c[0]=(a[0].x+a[b].x)/2,1;if(m(a,b))return c[0]=n(a,b),1}o(a,b,.5,h,i),e=k(h,b,j,d+1),g=k(i,b,p,d+1);for(var q=0;e>q;q++)c[q]=j[q];for(var q=0;g>q;q++)c[q+e]=p[q];return e+g},l=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},m=function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;var t,u;t=u=0;for(var v=1;b>v;v++){var w=i*a[v].x+j*a[v].y+k;w>t?t=w:u>w&&(u=w)}return n=0,o=1,p=0,q=i,r=j,s=k-t,l=n*r-q*o,m=1/l,d=(o*s-r*p)*m,q=i,r=j,s=k-u,l=n*r-q*o,m=1/l,e=(o*s-r*p)*m,f=Math.min(d,e),h=Math.max(d,e),c=h-f,g>c?1:0},n=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},o=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},p={},q=function(a){var b=p[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(b){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),p[a]=b}return b},r=function(a,b){for(var c=q(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=r(a,d),c+=s(f,b),b=f;return c},w=function(a,b,c){return u(a,b,c).point},x=function(a,b,c){return u(a,b,c).location},y=function(a,b){var c=r(a,b),d=r(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0===e?1/0:Math.atan(e/f)},z=function(a,b,c){var d=u(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),y(a,d.location)},A=function(a,b,c,d){d=null==d?0:d;var e=u(a,b,d),f=y(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]},B=function(a,c,e,f,g){var h=f-c,i=a-e,j=a*(c-f)+c*(e-a),k=b(g),l=[h*k[0][0]+i*k[1][0],h*k[0][1]+i*k[1][1],h*k[0][2]+i*k[1][2],h*k[0][3]+i*k[1][3]+j],m=d.apply(null,l),n=[];if(null!=m)for(var o=0;3>o;o++){var p,q=m[o],r=Math.pow(q,2),s=Math.pow(q,3),t=[k[0][0]*s+k[0][1]*r+k[0][2]*q+k[0][3],k[1][0]*s+k[1][1]*r+k[1][2]*q+k[1][3]];p=e-a!==0?(t[0]-a)/(e-a):(t[1]-c)/(f-c),q>=0&&1>=q&&p>=0&&1>=p&&n.push(t)}return n},C=function(a,b,c,d,e){var f=[];return f.push.apply(f,B(a,b,a+c,b,e)),f.push.apply(f,B(a+c,b,a+c,b+d,e)),f.push.apply(f,B(a+c,b+d,a,b+d,e)),f.push.apply(f,B(a,b+d,a,b,e)),f},D=function(a,b){var c=[];return c.push.apply(c,B(a.x,a.y,a.x+a.w,a.y,b)),c.push.apply(c,B(a.x+a.w,a.y,a.x+a.w,a.y+a.h,b)),c.push.apply(c,B(a.x+a.w,a.y+a.h,a.x,a.y+a.h,b)),c.push.apply(c,B(a.x,a.y+a.h,a.x,a.y,b)),c},E=this.jsBezier={distanceFromCurve:h,gradientAtPoint:y,gradientAtPointAlongCurveFrom:z,nearestPointOnCurve:i,pointOnCurve:r,pointAlongCurveFrom:w,perpendicularToCurveAt:A,locationAlongCurveFrom:x,getLength:v,lineIntersection:B,boxIntersection:C,boundingBoxIntersection:D,version:"0.9.0"};"undefined"!=typeof exports&&(exports.jsBezier=E)}).call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.Biltong={version:"0.4.0"};"undefined"!=typeof exports&&(exports.Biltong=b);var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a,b,d){return a=c(a)?a:[a.x,a.y],b=c(b)?b:[b.x,b.y],d(a,b)},e=b.gradient=function(a,b){return d(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-(1/0):b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},f=(b.normal=function(a,b){return-1/e(a,b)},b.lineLength=function(a,b){return d(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},b.quadrant=function(a,b){return d(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),g=(b.theta=function(a,b){return d(a,b,function(a,b){var c=e(a,b),d=Math.atan(c),g=f(a,b);return(4==g||3==g)&&(d+=Math.PI),0>d&&(d+=2*Math.PI),d})},b.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},b.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),h=[null,[-1,-1],[-1,1],[1,1],[1,-1]];b.pointOnLine=function(a,b,c){var d=e(a,b),i=f(a,b),j=c>0?g[i]:h[i],k=Math.atan(d),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},b.perpendicularLineTo=function(a,b,c){var d=e(a,b),f=Math.atan(-1/d),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call("undefined"!=typeof window?window:this),function(){"use strict";function a(a,b,c,d,e,f,g,h){return new Touch({target:b,identifier:J(),pageX:c,pageY:d,screenX:e,screenY:f,clientX:g||e,clientY:h||f})}function b(){var a=[];return Array.prototype.push.apply(a,arguments),a.item=function(a){return this[a]},a}function c(c,d,e,f,g,h,i,j){return b(a.apply(null,arguments))}var d=this,e=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>x,z=function(a,b){if(null==a)return[0,0];var c=E(a),d=D(c,0);return[d[b+"X"],d[b+"Y"]]},A=function(a){return null==a?[0,0]:y?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:z(a,"page")},B=function(a){return z(a,"screen")},C=function(a){return z(a,"client")},D=function(a,b){return a.item?a.item(b):a[b]},E=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},F=function(a){return E(a).length},G=function(a,b,c,d){if(k(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},H=function(a,b,c){null!=c&&I(a,function(){var d=f(this);if(l(d,b,c),null!=c.__tauid)if(d.removeEventListener)d.removeEventListener(b,c,!1),u&&w[b]&&d.removeEventListener(w[b],c,!1);else if(this.detachEvent){var e=b+c.__tauid;d[e]&&d.detachEvent("on"+b,d[e]),d[e]=null,d["e"+e]=null}c.__taTouchProxy&&H(a,c.__taTouchProxy[1],c.__taTouchProxy[0])})},I=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c-1&&9>j,n=9===j,o=function(a){if(m)return[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop];var b=q(a),c=p(b,0);return n?[c.pageX||c.clientX,c.pageY||c.clientY]:[c.pageX,c.pageY]},p=function(a,b){return a.item?a.item(b):a[b]},q=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},r={delegatedDraggable:"katavorio-delegated-draggable",draggable:"katavorio-draggable",droppable:"katavorio-droppable",drag:"katavorio-drag",selected:"katavorio-drag-selected",active:"katavorio-drag-active",hover:"katavorio-drag-hover",noSelect:"katavorio-drag-no-select",ghostProxy:"katavorio-ghost-proxy",clonedDrag:"katavorio-clone-drag"},s="katavorio-drag-scope",t=["stop","start","drag","drop","over","out","beforeStart"],u=function(){},v=function(){return!0},w=function(a,b,c){for(var d=0;d0){var e=i(O,this.el,a.target||a.srcElement);if(null!=e&&(P=e[0],N=e[1]),null==N)return}else N=this.el;if(G)if(F=N.cloneNode(!0),this.params.addClass(F,r.clonedDrag),F.setAttribute("id",null),F.style.position="absolute",null!=this.params.parent){var g=this.params.getPosition(this.el);F.style.left=g[0]+"px",F.style.top=g[1]+"px",this.params.parent.appendChild(F)}else{var j=f(N);F.style.left=j.left+"px",F.style.top=j.top+"px",document.body.appendChild(F)}else F=N;A&&z(a),q=o(a),F&&F.parentNode&&(y=[F.parentNode.scrollLeft,F.parentNode.scrollTop]),this.params.bind(document,"mousemove",this.moveListener),this.params.bind(document,"mouseup",this.upListener),h.markSelection(this),h.markPosses(this),this.params.addClass(document.body,c.noSelect),ea("beforeStart",{el:this.el,pos:s,e:a,drag:this})}else this.params.consumeFilteredEvents&&z(a)}}}.bind(this),this.moveListener=function(a){if(q){if(!w){var b=ea("start",{el:this.el,pos:s,e:a,drag:this});if(b!==!1){if(!q)return;this.mark(!0),w=!0}else this.abort()}if(q){ca.length=0;var c=o(a),d=c[0]-q[0],e=c[1]-q[1],f=this.params.ignoreZoom?1:h.getZoom();F&&F.parentNode&&(d+=F.parentNode.scrollLeft-y[0],e+=F.parentNode.scrollTop-y[1]),d/=f,e/=f,this.moveBy(d,e,a),h.updateSelection(d,e,this),h.updatePosses(d,e,this)}}}.bind(this),this.upListener=function(a){q&&(q=null,this.params.unbind(document,"mousemove",this.moveListener),this.params.unbind(document,"mouseup",this.upListener),this.params.removeClass(document.body,c.noSelect),this.unmark(a),h.unmarkSelection(this,a),h.unmarkPosses(this,a),this.stop(a),h.notifyPosseDragStop(this,a),w=!1,ca.length=0,G?(F&&F.parentNode&&F.parentNode.removeChild(F),F=null):X&&X(F,this.params.getPosition(F))===!0&&(this.params.setPosition(F,s),ea("revert",F)))}.bind(this),this.getFilters=function(){return Z},this.abort=function(){null!=q&&this.upListener()},this.getDragElement=function(a){return a?N||this.el:F||this.el};var da={start:[],drag:[],stop:[],over:[],out:[],beforeStart:[],revert:[]};b.events.start&&da.start.push(b.events.start),b.events.beforeStart&&da.beforeStart.push(b.events.beforeStart),b.events.stop&&da.stop.push(b.events.stop),b.events.drag&&da.drag.push(b.events.drag),b.events.revert&&da.revert.push(b.events.revert),this.on=function(a,b){da[a]&&da[a].push(b)},this.off=function(a,b){if(da[a]){for(var c=[],d=0;d0&&fa&&b.setPosition(N,fa),ca.sort(I);for(var e=0;eb.rank?-1:0},J=function(a){return null==a?null:(a="string"==typeof a||a.constructor===String?document.getElementById(a):a,null==a?null:(a._katavorio=a._katavorio||H(),a))};a.Katavorio=function(a){var f=[],g={};this._dragsByScope={},this._dropsByScope={};var h=1,i=function(a,b){y(a,function(a){for(var c=0;c0},k=(this.getMatchingDroppables=function(a){for(var b=[],c={},d=0;d=0&&f.splice(d,1),j(a[b],c)&&y(a[b],function(a){a.destroy()}),delete a[b]}},B=function(a,b,c,d){a=J(a),a[b]&&a[b].off(c,d)};this.elementRemoved=function(a){this.destroyDraggable(a),this.destroyDroppable(a)},this.destroyDraggable=function(a,b,c){1===arguments.length?z(a,"_katavorioDrag",this._dragsByScope):B(a,"_katavorioDrag",b,c)},this.destroyDroppable=function(a,b,c){1===arguments.length?z(a,"_katavorioDrop",this._dropsByScope):B(a,"_katavorioDrop",b,c)},this.reset=function(){this._dragsByScope={},this._dropsByScope={},f=[],g={},C={}};var C={},D=function(a,c,d){var f=e(c)?c:c.id,g=e(c)?!0:c.active!==!1,h=C[f]||function(){var a={name:f,members:[]};return C[f]=a,a}();return y(a,function(a){if(a._katavorioDrag){if(d&&null!=a._katavorioDrag.posseRoles[h.name])return;b(h.members,a._katavorioDrag),b(a._katavorioDrag.posses,h.name),a._katavorioDrag.posseRoles[h.name]=g}}),h};this.addToPosse=function(a,b){for(var c=[],d=1;d0}function j(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}function k(b){if(c(b))return""+b;if(d(b))return!!b;if(g(b))return new Date(b.getTime());if(h(b))return b;if(a(b)){for(var e=[],i=0;i=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}();return""}),a}}function n(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!==c}function r(a,b){var c=a.indexOf(b);return c>-1&&a.splice(c,1),-1!==c}function s(a,b,c){-1===p(a,c)&&a.push(b)}function t(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e}function u(a,b,c){return-1===a.indexOf(b)?(c?a.unshift(b):a.push(b),!0):!1}function v(b,c,d){var e;c=a(c)?c:[c];var f=function(a){for(var c=a.__proto__;null!=c;)if(null!=c.prototype){for(var d in c.prototype)c.prototype.hasOwnProperty(d)&&!b.prototype.hasOwnProperty(d)&&(b.prototype[d]=c.prototype[d]);c=c.prototype.__proto__}else c=null};for(e=0;e2)for(e=2;ee&&g!==!1;){if(this.eventsToDieOn[a])this._listeners[a][e].apply(this,[b,c]);else try{g=this._listeners[a][e].apply(this,[b,c])}catch(h){B("jsPlumb: fire failed for event "+a+" : "+h)}e++,(null==this._listeners||null==this._listeners[a])&&(f=!0)}}this.tick=!1,this._drain()}return this},this._drain=function(){var b=a.queue.pop();b&&a.fire.apply(a,b)},this.unbind=function(a,b){if(0===arguments.length)this._listeners={};else if(1===arguments.length){if("string"==typeof a)delete this._listeners[a];else if(a.__jsPlumb){var c=void 0;for(var d in a.__jsPlumb)c=a.__jsPlumb[d],r(this._listeners[c]||[],a)}}else 2===arguments.length&&r(this._listeners[a]||[],b);return this},this.getListener=function(b){return a._listeners[b]},this.setSuspendEvents=function(b){a.eventsSuspended=b},this.isSuspendEvents=function(){return a.eventsSuspended},this.silently=function(b){a.setSuspendEvents(!0);try{b()}catch(c){B("Cannot execute silent function "+c)}a.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a._listeners)a._listeners[b]=null}}return a}();E.EventGenerator=F}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this;a.jsPlumbUtil.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;eb.scrollTop+b.offsetHeight)d[i]._jsPlumbProxies||(d[i]._jsPlumbProxies=d[i]._jsPlumbProxies||[],a.select({source:d[i]}).each(function(c){a.proxyConnection(c,0,b,h,function(){return f("bottom",0,c.endpoints[0],c)},function(){return e("bottom",0,c.endpoints[0],c)}),d[i]._jsPlumbProxies.push([c,0])}),a.select({target:d[i]}).each(function(c){a.proxyConnection(c,1,b,h,function(){return f("bottom",1,c.endpoints[1],c)},function(){return e("bottom",1,c.endpoints[1],c)}),d[i]._jsPlumbProxies.push([c,1])}));else if(d[i]._jsPlumbProxies){for(var j=0;jf;f++)d&&d===e[f]||e[f].setHover(b,!0,c)},g=function(a){return null==a?null:a.split(" ")},h=function(a,b,c){for(var d in b)a[d]=c},i=function(a,c,d){if(a.getDefaultType){var e=a.getTypeDescriptor(),f={},g=a.getDefaultType(),i=b.merge({},g);h(f,g,"__default");for(var j=0,k=a._jsPlumb.types.length;k>j;j++){var l=a._jsPlumb.types[j];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(i=b.merge(i,m,["cssClass"],["connector"]),h(f,m,l))}}c&&(i=b.populate(i,c,"_")),a.applyType(i,d,f),d||a.repaint()}},j=a.jsPlumbUIComponent=function(a){b.EventGenerator.apply(this,arguments);var c=this,d=arguments,e=c.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&i(this,b,c)}},removeType:function(a,b,c){var d=g(a),e=!1,f=function(a){var b=this._jsPlumb.types.indexOf(a);return-1!==b?(k(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=d){for(var h=0,j=d.length;j>h;h++)e=f(d[h])||e;e&&i(this,b,c)}},clearTypes:function(a,b){for(var c=this._jsPlumb.types.length,d=0;c>d;d++)k(this,0),this._jsPlumb.types.splice(0,1);i(this,a,b)},toggleType:function(a,b,c){var d=g(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var h=this._jsPlumb.types.indexOf(d[e]);-1!==h?(k(this,h),this._jsPlumb.types.splice(h,1)):this._jsPlumb.types.push(d[e])}i(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,d(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,d(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,d){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){this._jsPlumb.hover=a;var e=a?"addClass":"removeClass";null!=this.canvas&&(null!=this._jsPlumb.instance.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.instance.hoverClass),null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[e](this.canvas,this._jsPlumb.hoverClass)),null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(d=d||c(),this.repaint({timestamp:d,recalc:!1}))),this.getAttachedElements&&!b&&f(this,a,c(),this)}}});var l=0,m=function(){var a=l+1;return l++,a},n=a.jsPlumbInstance=function(d){this.version="2.10.0",this.Defaults={Anchor:"Bottom",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fill:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{"stroke-width":4,stroke:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},d&&o.extend(this.Defaults,d),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},b.EventGenerator.apply(this);var f=this,g=m(),h=f.bind,i={},k=1,l=function(a){if(null==a)return null;if(3===a.nodeType||8===a.nodeType)return{el:a,text:!0};var c=f.getElement(a);return{el:c,id:b.isString(a)&&null==c?a:T(c)}};this.getInstanceIndex=function(){return g},this.setZoom=function(a,b){return k=a,f.fire("zoom",k),b&&f.repaintEverything(),!0},this.getZoom=function(){return k};for(var n in this.Defaults)i[n]=this.Defaults[n];var p,q=[];this.unbindContainer=function(){if(null!=p&&q.length>0)for(var a=0;ae;e++)d.overlays.push(d.sourceEndpoint.connectorOverlays[e])}d.sourceEndpoint&&d.sourceEndpoint.scope&&(d.scope=d.sourceEndpoint.scope),!d["pointer-events"]&&d.sourceEndpoint&&d.sourceEndpoint.connectorPointerEvents&&(d["pointer-events"]=d.sourceEndpoint.connectorPointerEvents);var h=function(a,b,c){return f.addEndpoint(a,K(b,{anchor:d.anchors?d.anchors[c]:d.anchor,endpoint:d.endpoints?d.endpoints[c]:d.endpoint,paintStyle:d.endpointStyles?d.endpointStyles[c]:d.endpointStyle,hoverPaintStyle:d.endpointHoverStyles?d.endpointHoverStyles[c]:d.endpointHoverStyle}))},i=function(a,b,c,e){if(d[a]&&!d[a].endpoint&&!d[a+"Endpoint"]&&!d.newConnection){var f=T(d[a]),g=c[f];if(g=g?g[e]:null){if(!g.enabled)return!1;var i=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:h(d[a],g.def,b);if(i.isFull())return!1;d[a+"Endpoint"]=i,!d.scope&&g.def.scope&&(d.scope=g.def.scope),g.uniqueEndpoint?g.endpoint?i.finalEndpoint=g.endpoint:(g.endpoint=i,i.setDeleteOnEmpty(!1)):i.setDeleteOnEmpty(!0),0===b&&g.def.connectorOverlays&&(d.overlays=d.overlays||[],Array.prototype.push.apply(d.overlays,g.def.connectorOverlays))}}};return i("source",0,this.sourceEndpointDefinitions,d.type||"default")!==!1&&i("target",1,this.targetEndpointDefinitions,d.type||"default")!==!1?(d.sourceEndpoint&&d.targetEndpoint&&(J(d.sourceEndpoint,d.targetEndpoint)||(d=null)),d):void 0}.bind(f),M=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=M,a.newEndpoint=O,a.endpointsByUUID=v,a.endpointsByElement=u,a.finaliseConnection=N,a.id="con_"+F();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable("_jsPlumbSource"),c.endpoints[1].initDraggable("_jsPlumbTarget")),c},N=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||t.push(a),a.pending=null,a.endpoints[0].isTemporarySource=!1,d!==!1&&f.anchorManager.newConnection(a),H(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},O=function(a,b){var c=f.Defaults.EndpointType||o.Endpoint,d=o.extend({},a);d._jsPlumb=f,d.newConnection=M,d.newEndpoint=O,d.endpointsByUUID=v,d.endpointsByElement=u,d.fireDetachEvent=W,d.elementId=b||T(d.source);var e=new c(d);return e.id="ep_"+F(),na(d.elementId,d.source),o.headless||f.getDragManager().endpointAdded(d.source,b),e},P=function(a,b,c){var d=u[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},Q=function(a,b,c){b="block"===b;var d=null;c&&(d=function(a){a.setVisible(b,!0,!0)});var e=l(a);P(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},R=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),P(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},S=function(a){var b=x[a];return b?{o:b,s:A[a]}:oa({elId:a})},T=function(a,c,d){if(b.isString(a))return a;if(null==a)return null;var e=f.getAttribute(a,"id");return e&&"undefined"!==e||(2===arguments.length&&void 0!==arguments[1]?e=c:(1===arguments.length||3===arguments.length&&!arguments[2])&&(e="jsPlumb_"+g+"_"+F()),d||f.setAttribute(a,"id",e)),e};this.setConnectionBeingDragged=function(a){z=a},this.isConnectionBeingDragged=function(){return z},this.getManagedElements=function(){return w},this.connectorClass="jtk-connector",this.connectorOutlineClass="jtk-connector-outline",this.connectedClass="jtk-connected",this.hoverClass="jtk-hover",this.endpointClass="jtk-endpoint",this.endpointConnectedClass="jtk-endpoint-connected",this.endpointFullClass="jtk-endpoint-full",this.endpointDropAllowedClass="jtk-endpoint-drop-allowed",this.endpointDropForbiddenClass="jtk-endpoint-drop-forbidden",this.overlayClass="jtk-overlay",this.draggingClass="jtk-dragging",this.elementDraggingClass="jtk-element-dragging",this.sourceElementDraggingClass="jtk-source-element-dragging",this.targetElementDraggingClass="jtk-target-element-dragging",this.endpointAnchorClassPrefix="jtk-endpoint-anchor",this.hoverSourceClass="jtk-source-hover",this.hoverTargetClass="jtk-target-hover",this.dragSelectClass="jtk-drag-select",this.Anchors={},this.Connectors={svg:{}},this.Endpoints={svg:{}},this.Overlays={svg:{}},this.ConnectorRenderers={},this.SVG="svg",this.addEndpoint=function(a,c,d){d=d||{};var e=o.extend({},d);o.extend(e,c),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=b.isArray(a)||null!=a.length&&!b.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),la(e.source);var k=T(e.source),l=O(e,k),m=na(k,e.source).info.o;b.addToList(u,k,l),B||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:A[k],element:l,timestamp:C}),timestamp:C}),g.push(l)}return 1===g.length?g[0]:g},this.addEndpoints=function(a,c,d){for(var e=[],g=0,h=c.length;h>g;g++){var i=f.addEndpoint(a,c[g],d);b.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,c,d){if(!this.animationSupported)return!1;d=d||{};var e=f.getElement(a),g=T(e),h=o.animEvents.step,i=o.animEvents.complete;d[h]=b.wrap(d[h],function(){f.revalidate(g)}),d[i]=b.wrap(d[i],function(){f.revalidate(g)}),f.doAnimate(e,c,d)},this.checkCondition=function(a,c){var d=f.getListener(a),e=!0;if(d&&d.length>0){var g=Array.prototype.slice.call(arguments,1);try{for(var h=0,i=d.length;i>h;h++)e=e&&d[h].apply(d[h],g)}catch(j){b.log(f,"cannot check condition ["+a+"]"+j)}}return e},this.connect=function(a,c){var d,e=L(a,c);if(e){if(null==e.source&&null==e.sourceEndpoint)return void b.log("Cannot establish connection - source does not exist");if(null==e.target&&null==e.targetEndpoint)return void b.log("Cannot establish connection - target does not exist");la(e.source),d=M(e),N(d,e)}return d};var U=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],V=function(a,b,c,d){var e,f,g,h=U[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1===c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor===o.Endpoint)e=b,e.addConnection(a),b=e.element;else if(f=T(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g)for(var l in g){if(!g[l].enabled)return;e=null!=g[l].endpoint&&g[l].endpoint._jsPlumb?g[l].endpoint:this.addEndpoint(b,g[l].def),g[l].uniqueEndpoint&&(g[l].endpoint=e),e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f);return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,X(k),d||a.repaint()),k.element=b,k}.bind(this);this.setSource=function(a,b,c){var d=V(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a,d.el)},this.setTarget=function(a,b,c){var d=V(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b,c){var d="string"==typeof a?v[a]:a;return d&&f.deleteObject({endpoint:d,dontUpdateHover:b,deleteAttachedObjects:c}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in u){var c=u[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}u={},w={},v={},x={},y={},f.anchorManager.reset();var g=f.getDragManager();return g&&g.reset(),a||f.setSuspendDrawing(!1),f};var W=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor===d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.fire("internal.connectionDetached",g,c),f.anchorManager.connectionDetached(g)},X=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(v[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in u){var c=u[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!==a&&d.push(c[e]);u[b]=d; +}u[b].length<1&&delete u[b]}};var Y="isDetachAllowed",Z="beforeDetach",$="checkCondition";this.deleteConnection=function(a,c){return null!=a&&(c=c||{},c.force||b.functionChain(!0,!1,[[a.endpoints[0],Y,[a]],[a.endpoints[1],Y,[a]],[a,Y,[a]],[f,$,[Z,a]]]))?(a.setHover(!1),W(a,!a.pending&&c.fireEvent!==!1,c.originalEvent),a.endpoints[0].detachFromConnection(a),a.endpoints[1].detachFromConnection(a),b.removeWithFunction(t,function(b){return a.id===b.id}),a.cleanup(),a.destroy(),!0):!1},this.deleteEveryConnection=function(a){a=a||{};var b=t.length,c=0;return f.batch(function(){for(var d=0;b>d;d++)c+=f.deleteConnection(t[0],a)?1:0}),c},this.deleteConnectionsForElement=function(a,b){b=b||{},a=f.getElement(a);var c=T(a),d=u[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].deleteEveryConnection(b);return f},this.deleteObject=function(a){var c={endpoints:{},connections:{},endpointCount:0,connectionCount:0},d=a.deleteAttachedObjects!==!1,e=function(b){null!=b&&null==c.connections[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.connections[b.id]=b,c.connectionCount++)},g=function(b){if(null!=b&&null==c.endpoints[b.id]&&(a.dontUpdateHover||null==b._jsPlumb||b.setHover(!1),c.endpoints[b.id]=b,c.endpointCount++,d))for(var f=0;fe;e++)a[e][b].apply(a[e],c);return d(a)},aa=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},ba=function(a,b,c){return function(){return _(a,b,arguments,c)}},ca=function(a,b){return function(){return aa(a,b,arguments)}},da=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(l(a[d]).id);else c.push(l(a).id);return c},ea=function(a,b,c){return"*"===a?!0:a.length>0?-1!==a.indexOf(b):!c};this.getConnections=function(a,b){a?a.constructor===String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=da(c,!0),e=da(a.source),g=da(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=t.length;k>j;j++){var l=t[j],m=l.proxies&&l.proxies[0]?l.proxies[0].originalEp.elementId:l.sourceId,n=l.proxies&&l.proxies[1]?l.proxies[1].originalEp.elementId:l.targetId;ea(d,l.scope)&&ea(e,m)&&ea(g,n)&&i(l.scope,l)}return h};var fa=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},ga=function(a){return function(b){return a[b]}},ha=function(a,b){var c,d,e={length:a.length,each:fa(a,b),get:ga(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=ba(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=ca(a,g[c]);return e},ia=function(a){var b=ha(a,ia);return o.extend(b,{setDetachable:ba(a,"setDetachable",ia),setReattach:ba(a,"setReattach",ia),setConnector:ba(a,"setConnector",ia),"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteConnection(a[b])},isDetachable:ca(a,"isDetachable"),isReattach:ca(a,"isReattach")})},ja=function(a){var b=ha(a,ja);return o.extend(b,{setEnabled:ba(a,"setEnabled",ja),setAnchor:ba(a,"setAnchor",ja),isEnabled:ca(a,"isEnabled"),deleteEveryConnection:function(){for(var b=0,c=a.length;c>b;b++)a[b].deleteEveryConnection()},"delete":function(){for(var b=0,c=a.length;c>b;b++)f.deleteEndpoint(a[b])}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",ia(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":da(a.element),d=b?"*":da(a.source),e=b?"*":da(a.target),f=da(a.scope,!0),g=[];for(var h in u){var i=ea(c,h,!0),j=ea(d,h,!0),k="*"!==d,l=ea(e,h,!0),m="*"!==e;if(i||j||l)a:for(var n=0,o=u[h].length;o>n;n++){var p=u[h][n];if(ea(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return ja(g)},this.getAllConnections=function(){return t},this.getDefaultScope=function(){return D},this.getEndpoint=I,this.getEndpoints=function(a){return u[l(a).id]||[]},this.getDefaultEndpointType=function(){return o.Endpoint},this.getDefaultConnectionType=function(){return o.Connection},this.getId=T,this.draw=H,this.info=l,this.appendElement=G;var ka=!1;this.isHoverSuspended=function(){return ka},this.setHoverSuspended=function(a){ka=a},this.hide=function(a,b){return Q(a,"none",b),f},this.idstamp=F;var la=function(a){if(!p&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ma=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},na=f.manage=function(a,b,c){return w[a]||(w[a]={el:b,endpoints:[],connections:[]},w[a].info=oa({elId:a,timestamp:C}),f.addClass(b,"jtk-managed"),c||f.fire("manageElement",{id:a,info:w[a].info,el:b})),w[a]},oa=(f.unmanage=function(a){if(w[a]){var b=w[a].el;f.removeClass(b,"jtk-managed"),delete w[a],f.fire("unmanageElement",{id:a,el:b})}},function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return B&&!c&&(c=C),!d&&c&&c===y[g]?{o:a.offset||x[g],s:A[g]}:(d||!e&&null==x[g]?(b=w[g]?w[g].el:null,null!=b&&(A[g]=f.getSize(b),x[g]=f.getOffset(b),y[g]=c)):(x[g]=e||x[g],null==A[g]&&(b=w[g].el,null!=b&&(A[g]=f.getSize(b))),y[g]=c),x[g]&&!x[g].right&&(x[g].right=x[g].left+A[g][0],x[g].bottom=x[g].top+A[g][1],x[g].width=A[g][0],x[g].height=A[g][1],x[g].centerx=x[g].left+x[g].width/2,x[g].centery=x[g].top+x[g].height/2),{o:x[g],s:A[g]})});this.updateOffset=oa,this.init=function(){s||(ma(),f.anchorManager=new a.jsPlumb.AnchorManager({jsPlumbInstance:f}),s=!0,f.fire("ready",f))}.bind(this),this.log=r,this.jsPlumbUIComponent=j,this.makeAnchor=function(){var c,d=function(b,c){if(a.jsPlumb.Anchors[b])return new a.jsPlumb.Anchors[b](c);if(!f.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown anchor type '"+b+"'"}};if(0===arguments.length)return null;var e=arguments[0],g=arguments[1],h=(arguments[2],null);if(e.compute&&e.getOrientation)return e;if("string"==typeof e)h=d(arguments[0],{elementId:g,jsPlumbInstance:f});else if(b.isArray(e))if(b.isArray(e[0])||b.isString(e[0]))2===e.length&&b.isObject(e[1])?b.isString(e[0])?(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f},e[1]),h=d(e[0],c)):(c=a.jsPlumb.extend({elementId:g,jsPlumbInstance:f,anchors:e[0]},e[1]),h=new a.jsPlumb.DynamicAnchor(c)):h=new o.DynamicAnchor({anchors:e,selector:null,elementId:g,jsPlumbInstance:f});else{var i={x:e[0],y:e[1],orientation:e.length>=4?[e[2],e[3]]:[0,0],offsets:e.length>=6?[e[4],e[5]]:[0,0],elementId:g,jsPlumbInstance:f,cssClass:7===e.length?e[6]:null};h=new a.jsPlumb.Anchor(i),h.clone=function(){return new a.jsPlumb.Anchor(i)}}return h.id||(h.id="anchor_"+F()),h},this.makeAnchors=function(c,d,e){for(var g=[],h=0,i=c.length;i>h;h++)"string"==typeof c[h]?g.push(a.jsPlumb.Anchors[c[h]]({elementId:d,jsPlumbInstance:e})):b.isArray(c[h])&&g.push(f.makeAnchor(c[h],d,e));return g},this.makeDynamicAnchor=function(b,c){return new a.jsPlumb.DynamicAnchor({anchors:b,selector:c,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={};var pa=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&a>=c.def.maxConnections},element:c.el,elementId:c.id,isSource:g,isTarget:h,addClass:function(a){f.addClass(c.el,a)},removeClass:function(a){f.removeClass(c.el,a)},onDrop:function(a){var b=a.endpoints[0];b.anchor.unlock()},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(a){return null!=a.suspendedElement&&null!=a.suspendedEndpoint&&a.suspendedEndpoint.element===c.el},getEndpoint:function(b){var e=c.def.endpoint;if(null==e||null==e._jsPlumb){var g=f.deriveEndpointAndAnchorSpec(b.getType().join(" "),!0),h=g.endpoints?a.jsPlumb.extend(d,{endpoint:c.def.def.endpoint||g.endpoints[1]}):d;g.anchors&&(h=a.jsPlumb.extend(h,{anchor:c.def.def.anchor||g.anchors[1]})),e=f.addEndpoint(c.el,h),e._mtNew=!0}if(d.uniqueEndpoint&&(c.def.endpoint=e),e.setDeleteOnEmpty(!0),b.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var i=f.getUIPosition(arguments,f.getZoom()),j=f.getOffset(c.el),k=f.getSize(c.el),l=null==i?[0,0]:e.anchor.positionFinder(i,j,k,e.anchor.constructorParams);e.anchor.x=l[0],e.anchor.y=l[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),l=a.jsPlumb.dragEvents.drop;return e.scope=e.scope||d.scope||f.Defaults.Scope,e[l]=b.wrap(e[l],k,!0),e.rank=d.rank||0,h&&(e[a.jsPlumb.dragEvents.over]=function(){return!0}),d.allowLoopback===!1&&(e.canDrop=function(a){var b=a.getDragElement()._jsPlumbRelatedElement;return b!==c.el}),f.initDroppable(c.el,e,"internal"),k};this.makeTarget=function(b,c,d){var e=a.jsPlumb.extend({_jsPlumb:this},d);a.jsPlumb.extend(e,c);for(var g=e.maxConnections||-1,h=function(b){var c=l(b),d=c.id,h=a.jsPlumb.extend({},e.dropOptions||{}),i=e.connectionType||"default";this.targetEndpointDefinitions[d]=this.targetEndpointDefinitions[d]||{},la(d),c.el._isJsPlumbGroup&&null==h.rank&&(h.rank=-1);var j={def:a.jsPlumb.extend({},e),uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};e.createEndpoint&&(j.uniqueEndpoint=!0,j.endpoint=f.addEndpoint(b,j.def),j.endpoint.setDeleteOnEmpty(!1)),c.def=j,this.targetEndpointDefinitions[d][i]=j,qa(c,e,h,e.isSource===!0,!0),c.el._katavorioDrop[c.el._katavorioDrop.length-1].targetDef=j}.bind(this),i=b.length&&b.constructor!==String?b:[b],j=0,k=i.length;k>j;j++)h(i[j]);return this},this.unmakeTarget=function(a,b){var c=l(a);return f.destroyDroppable(c.el,"internal"),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(c,d,e){var g=a.jsPlumb.extend({_jsPlumb:this},e);a.jsPlumb.extend(g,d);var h=g.connectionType||"default",i=f.deriveEndpointAndAnchorSpec(h);g.endpoint=g.endpoint||i.endpoints[0],g.anchor=g.anchor||i.anchors[0];for(var j=g.maxConnections||-1,m=g.onMaxConnections,n=function(d){var e=d.id,i=this.getElement(d.el);this.sourceEndpointDefinitions[e]=this.sourceEndpointDefinitions[e]||{},la(e);var l={def:a.jsPlumb.extend({},g),uniqueEndpoint:g.uniqueEndpoint,maxConnections:j,enabled:!0};g.createEndpoint&&(l.uniqueEndpoint=!0,l.endpoint=f.addEndpoint(c,l.def),l.endpoint.setDeleteOnEmpty(!1)),this.sourceEndpointDefinitions[e][h]=l,d.def=l;var n=a.jsPlumb.dragEvents.stop,o=a.jsPlumb.dragEvents.drag,p=a.jsPlumb.extend({},g.dragOptions||{}),q=p.drag,r=p.stop,s=null,t=!1;p.scope=p.scope||g.scope,p[o]=b.wrap(p[o],function(){q&&q.apply(this,arguments),t=!1}),p[n]=b.wrap(p[n],function(){if(r&&r.apply(this,arguments),this.currentlyDragging=!1,null!=s._jsPlumb){var a=g.anchor||this.Defaults.Anchor,b=s.anchor,c=s.connections[0],d=this.makeAnchor(a,e,this),h=s.element;if(null!=d.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+b.x*j[0],top:i.top+b.y*j[1]},l=d.positionFinder(k,i,j,d.constructorParams);d.x=l[0],d.y=l[1]}s.setAnchor(d,!0),s.repaint(),this.repaint(s.elementId),null!=c&&this.repaint(c.targetId)}}.bind(this));var u=function(c){if(3!==c.which&&2!==c.button){var l=this.sourceEndpointDefinitions[e][h];if(l.enabled){if(e=this.getId(this.getElement(d.el)),g.filter){var n=b.isString(g.filter)?pa(c,d.el,g.filter,this,g.filterExclude):g.filter(c,d.el);if(n===!1)return}var o=this.select({source:e}).length;if(l.maxConnections>=0&&o>=l.maxConnections)return m&&m({element:d.el,maxConnections:j},c),!1;var q=a.jsPlumb.getPositionOnElement(c,i,k),r={};a.jsPlumb.extend(r,g),r.isTemporarySource=!0,r.anchor=[q[0],q[1],0,0],r.dragOptions=p,l.def.scope&&(r.scope=l.def.scope),s=this.addEndpoint(e,r),t=!0,s.setDeleteOnEmpty(!0),l.uniqueEndpoint&&(l.endpoint?s.finalEndpoint=l.endpoint:(l.endpoint=s,s.setDeleteOnEmpty(!1)));var u=function(){f.off(s.canvas,"mouseup",u),f.off(d.el,"mouseup",u),t&&(t=!1,f.deleteEndpoint(s))};f.on(s.canvas,"mouseup",u),f.on(d.el,"mouseup",u);var v={};if(l.def.extract)for(var w in l.def.extract){var x=(c.srcElement||c.target).getAttribute(w);x&&(v[l.def.extract[w]]=x)}f.trigger(s.canvas,"mousedown",c,v),b.consume(c)}}}.bind(this);this.on(d.el,"mousedown",u),l.trigger=u,g.filter&&(b.isString(g.filter)||b.isFunction(g.filter))&&f.setDragFilter(d.el,g.filter);var v=a.jsPlumb.extend({},g.dropOptions||{});qa(d,g,v,!0,g.isTarget===!0)}.bind(this),o=c.length&&c.constructor!==String?c:[c],p=0,q=o.length;q>p;p++)n(l(o[p]));return this},this.unmakeSource=function(a,b,c){var d=l(a);f.destroyDroppable(d.el,"internal");var e=this.sourceEndpointDefinitions[d.id];if(e)for(var g in e)if(null==b||b===g){var h=e[g].trigger;h&&f.off(d.el,"mousedown",h),c||delete this.sourceEndpointDefinitions[d.id][g]}return this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,null,!0);return this.sourceEndpointDefinitions={},this};var ra=function(a,c,d){c=b.isArray(c)?c:[c];var e=T(a);d=d||"default";for(var f=0;fm;m++)i=l(c[m]),k[i.id]&&k[i.id][g]&&(h[m]=k[i.id][g].enabled,j=e?!h[m]:d,k[i.id][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}else{i=l(c);var o=i.id;k[o]&&k[o][g]&&(h=k[o][g].enabled,j=e?!h:d,k[o][g].enabled=j,f[j?"removeClass":"addClass"](i.el,"jtk-"+a+"-disabled"))}return h}.bind(this),ua=function(a,c){return b.isString(a)||!a.length?c.apply(this,[a]):a.length?c.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a,b){return ta("source",a,null,!0,b),this.isSourceEnabled(a,b)},this.setSourceEnabled=function(a,b,c){return ta("source",a,b,null,c)},this.isSource=function(a,b){return b=b||"default",ua(a,function(a){var c=this.sourceEndpointDefinitions[l(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isSourceEnabled=function(a,b){return b=b||"default",ua(a,function(a){var c=this.sourceEndpointDefinitions[l(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a,b){return ta("target",a,null,!0,b),this.isTargetEnabled(a,b)},this.isTarget=function(a,b){return b=b||"default",ua(a,function(a){var c=this.targetEndpointDefinitions[l(a).id];return null!=c&&null!=c[b]}.bind(this))},this.isTargetEnabled=function(a,b){return b=b||"default",ua(a,function(a){var c=this.targetEndpointDefinitions[l(a).id];return c&&c[b]&&c[b].enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b,c){return ta("target",a,b,null,c)},this.ready=function(a){f.bind("ready",a)};var va=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return va(a,function(a){H(a,b,c)})},this.revalidate=function(a,b,c){return va(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b});var e=f.getDragManager();e&&e.updateOffsets(d),f.repaint(a)})},this.repaintEverything=function(){var a,b=c();for(a in u)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in u)H(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=l(a),i=u[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e],!1);if(delete u[h.id],b&&h.el&&3!==h.el.nodeType&&8!==h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var wa=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=f.getDragManager(),d=function(a){c&&c.elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),f.isSource(a.el)&&f.unmakeSource(a.el),f.isTarget(a.el)&&f.unmakeTarget(a.el),f.destroyDraggable(a.el),f.destroyDroppable(a.el),delete f.floatingConnections[a.id],delete w[a.id],delete x[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},e=1;e0;)d(e.el.childNodes[0]);b||wa(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(a){f.silently(function(){ka=!1,f.removeAllGroups(),f.removeGroupManager(),f.deleteEveryEndpoint(),a||f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},t.length=0,this.doReset&&this.doReset()}.bind(this))};var xa=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(xa),f.selectEndpoints().each(xa),u={},v={}},this.setDefaultScope=function(a){return D=a,f},this.deriveEndpointAndAnchorSpec=function(a,b){for(var c=((b?"":"default ")+a).split(/[\s]/),d=null,e=null,g=null,h=null,i=0;ih;h++)u[c][h].setElementId(c),u[c][h].setReferenceElement(a);delete u[e],this.sourceEndpointDefinitions[c]=this.sourceEndpointDefinitions[e],delete this.sourceEndpointDefinitions[e],this.targetEndpointDefinitions[c]=this.targetEndpointDefinitions[e],delete this.targetEndpointDefinitions[e],this.anchorManager.changeId(e,c);var j=this.getDragManager();j&&j.changeId(e,c),w[c]=w[e],delete w[e];var k=function(b,d,e){for(var f=0,g=b.length;g>f;f++)b[f].endpoints[d].setElementId(c),b[f].endpoints[d].setReferenceElement(a),b[f][e+"Id"]=c,b[f][e]=a};k(f,0,"source"),k(g,1,"target"),this.repaint(c)},this.setDebugLog=function(a){r=a},this.setSuspendDrawing=function(a,b){var c=B;return B=a,C=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return B},this.getSuspendedAt=function(){return C},this.batch=function(a,c){var d=this.isSuspendDrawing();d||this.setSuspendDrawing(!0);try{a()}catch(e){b.log("Function run while suspended failed",e)}d||this.setSuspendDrawing(!1,!c)},this.doWhileSuspended=this.batch,this.getCachedData=S,this.timestamp=c,this.show=function(a,b){return Q(a,"block",b),f},this.toggleVisible=R,this.addListener=this.bind;var ya=[];this.registerFloatingConnection=function(a,c,d){ya[a.id]=c,b.addToList(u,a.id,d)},this.getFloatingConnectionFor=function(a){return ya[a]},this.listManager=new a.jsPlumbListManager(this)};b.extend(a.jsPlumbInstance,b.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(b,c){return this.getAttribute(a.jsPlumb.getElement(b),c)},convertToFullOverlaySpec:function(a){return b.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||b.uuid(),a},registerConnectionType:function(b,c){if(this._connectionTypes[b]=a.jsPlumb.extend({},c),c.overlays){for(var d={},e=0;ea;a++)this.removeOverlay(arguments[a])},moveParent:function(a){if(this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas&&this.canvas.parentNode){this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor===String||a.constructor===Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor===String||a.constructor===Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null},_clazzManip:function(a,b,c){if(!c)for(var d in this._jsPlumb.overlays)this._jsPlumb.overlays[d][a+"Class"](b)},addClass:function(a,b){this._clazzManip("add",a,b)},removeClass:function(a,b){this._clazzManip("remove",a,b)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,b,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;if(b.element){var e=c.getUIPosition(arguments,c.getZoom());null!=e&&c.setPosition(b.element,e),c.repaint(b.element,e),a.paint({anchorPoint:a.anchor.getCurrentLocation({element:a})})}},stopDrag:function(){d=!0}}},e=function(a,b,c,d){var e=b.createElement("div",{position:"absolute"});b.appendElement(e);var f=b.getId(e);b.setPosition(e,c),e.style.width=d[0]+"px",e.style.height=d[1]+"px",b.manage(f,e,!0),a.id=f,a.element=e},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?this.connections.indexOf(a):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](i.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](i.endpointFullClass)),!c&&m&&0===this.connections.length&&i.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:c!==!0})},this.deleteEveryConnection=function(a){for(var b=this.connections.length,c=0;b>c;c++)i.deleteConnection(this.connections[0],a)},this.detachFrom=function(a,b,c){for(var d=[],e=0;ef;f++)i.deleteConnection(d[0]);return this},this.getElement=function(){return this.element},this.setElement=function(d){var e=this._jsPlumb.instance.getId(d),f=this.elementId;return c.removeWithFunction(a.endpointsByElement[this.elementId],function(a){return a.id===this.id}.bind(this)),this.element=b.getElement(d),this.elementId=i.getId(this.element),i.anchorManager.rehomeEndpoint(this,f,this.element),i.dragManager.endpointAdded(this.element),c.addToList(a.endpointsByElement,e,this),this},this.makeInPlaceCopy=function(){var b=this.anchor.getCurrentLocation({element:this}),c=this.anchor.getOrientation(this),d=this.anchor.getCssClass(),e={bind:function(){},compute:function(){return[b[0],b[1]]},getCurrentLocation:function(){return[b[0],b[1]]},getOrientation:function(){return c},getCssClass:function(){return d}};return k({dropOptions:a.dropOptions,anchor:e,source:this.element,paintStyle:this.getPaintStyle(),endpoint:a.hideOnDrag?"Blank":this.endpoint,_transient:!0,scope:this.scope,reference:this})},this.connectorSelector=function(){return this.connections[0]},this.setStyle=this.setPaintStyle,this.paint=function(a){a=a||{};var b=a.timestamp,c=!(a.recalc===!1);if(!b||this.timestamp!==b){var d=i.updateOffset({elId:this.elementId,timestamp:b}),e=a.offset?a.offset.o:d.o;if(null!=e){var f=a.anchorPoint,g=a.connectorPaintStyle;if(null==f){var j=a.dimensions||d.s,k={xy:[e.left,e.top],wh:j,element:this,timestamp:b};if(c&&this.anchor.isDynamic&&this.connections.length>0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]===this?1:0,n=0===m?l.sourceId:l.targetId,o=i.getCachedData(n),p=o.o,q=o.s;k.index=0===m?1:0,k.connection=l,k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}else this.connections.length>0&&(k.connection=this.connections[0]);f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(){if(!p&&b.isDragSupported(this.element)){var g,h={id:null,element:null},m=null,n=!1,o=null,q=d(this,h,i),r=a.dragOptions||{},s={},t=b.dragEvents.start,u=b.dragEvents.stop,v=b.dragEvents.drag,w=b.dragEvents.beforeStart,x=function(a){g=a.e.payload||{}},y=function(c){m=this.connectorSelector();var d=!0;this.isEnabled()||(d=!1),null!=m||this.isSource||this.isTemporarySource||(d=!1),!this.isSource||!this.isFull()||null!=m&&this.dragAllowedWhenFull||(d=!1),null==m||m.isDetachable(this)||(this.isFull()?d=!1:m=null);var l=i.checkCondition(null==m?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:m});if(l===!1?d=!1:"object"==typeof l?b.extend(l,g||{}):l=g||{},d===!1)return i.stopDrag&&i.stopDrag(this.canvas),q.stopDrag(),!1;for(var p=0;p0&&this.connectionsDetachable!==!1}.bind(this),i.initDraggable(this.canvas,r,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:i.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,this.initDraggable();var t=function(d,e,f,g){if(b.isDropSupported(this.element)){var h=a.dropOptions||i.Defaults.DropOptions||b.Defaults.DropOptions;h=b.extend({},h),h.scope=h.scope||this.scope;var j=b.dragEvents.drop,k=b.dragEvents.over,l=b.dragEvents.out,m=this,n=i.EndpointDropHandler({getEndpoint:function(){return m},jsPlumb:i,enabled:function(){return null!=f?f.isEnabled():!0},isFull:function(){return f.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){m.addClass(a)},removeClass:function(a){m.removeClass(a)},isDropAllowed:function(){return m.isDropAllowed.apply(m,arguments)},reference:g,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});h[j]=c.wrap(h[j],n,!0),h[k]=c.wrap(h[k],function(){var a=b.getDragObject(arguments),c=i.getAttribute(b.getElement(a),"dragId"),d=i.getFloatingConnectionFor(c);if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;if(f){var g=i.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](i.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](i.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),h[l]=c.wrap(h[l],function(){var a=b.getDragObject(arguments),c=null==a?null:i.getAttribute(b.getElement(a),"dragId"),d=c?i.getFloatingConnectionFor(c):null;if(null!=d){var e=i.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id===d.suspendedEndpoint.id;f&&(this.removeClass(i.endpointDropAllowedClass),this.removeClass(i.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),i.initDroppable(d,h,"internal",e)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;dc[0][0],d===!1?-1:1}},n=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:-1},o={top:function(a,b){return a[0]>b[0]?1:-1},right:m(!0),bottom:m(!0),left:n},p=function(a,b){return a.sort(b)},q=function(a,b){var c=j.getCachedData(a),d=c.s,g=c.o,h=function(b,c,d,g,h,i,j){if(g.length>0)for(var k=p(g,o[b]),m="right"===b||"top"===b,n=l(b,c,d,k,h,i,m),q=function(a,b){ +e[a.id]=[b[0],b[1],b[2],b[3]],f[a.id]=j},r=0;r-1&&(g[d].splice(i,1),b.addToList(g,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor===c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e,f){if(a!==d){e.sourceId=d,e.source=f,b.removeWithFunction(g[a],function(a){return a[0].id===e.id});var h=b.findWithFunction(g[e.targetId],function(a){return a[0].id===e.id});h>-1&&(g[e.targetId][h][0]=e,g[e.targetId][h][1]=e.endpoints[0],g[e.targetId][h][2]=e.endpoints[0].anchor.constructor===c.DynamicAnchor),b.addToList(g,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor===c.DynamicAnchor]),e.endpoints[1].anchor.isContinuous&&(e.source===e.target?e._jsPlumb.instance.removeElement(e.endpoints[1].canvas):null==e.endpoints[1].canvas.parentNode&&e._jsPlumb.instance.appendElement(e.endpoints[1].canvas)),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,b,c){var e=d[b]||[],f=j.getId(c);if(f!==b){var g=e.indexOf(a);if(g>-1){var i=e.splice(g,1)[0];h.add(i,f)}}for(var k=0;kb.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;q0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.isLocked()||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!==f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.setAnchor=function(a){e=a},this.getCssClass=function(){return e&&e.getCssClass()||""},this.setAnchorCoordinates=function(a){var b=jsPlumbUtil.findWithFunction(this.anchors,function(b){return b.x===a[0]&&b.y===a[1]});return-1!==b?(this.setAnchor(this.anchors[b]),!0):!1}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor===String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),a.jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h,i,j){c=b*h;for(var k=(f-a)/c,l=(g-e)/c,m=0;c>m;m++)d.push([a+k*m,e+l*m,null==i?0:i,null==j?0:j])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(a){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)b?a>=b&&c>=a:b>=a&&a>=c},o=n;this.lineIntersection=function(a,b,c,f){var k=Math.abs(d.gradient({x:a,y:b},{x:c,y:f})),l=Math.abs(e),m=l===1/0?g:i-l*g,n=[],p=k===1/0?a:b-k*a;if(k!==l)if(k===1/0&&0===l)o(a,g,h)&&o(i,b,f)&&(n=[a,i]);else if(0===k&&l===1/0)o(b,i,j)&&o(g,a,c)&&(n=[g,b]);else{var q,r;k===1/0?(q=a,o(q,g,h)&&(r=l*a+m,o(r,b,f)&&(n=[q,r]))):0===k?(r=b,o(r,i,j)&&(q=(b-m)/l,o(q,a,c)&&(n=[q,r]))):(q=(p-m)/(l-k),r=l*q+m,o(q,g,h)&&o(r,i,j)&&(n=[q,r]))}return n},this.boxIntersection=function(a,b,c,d){var e=[];return e.push.apply(e,this.lineIntersection(a,b,a+c,b)),e.push.apply(e,this.lineIntersection(a+c,b,a+c,b+d)),e.push.apply(e,this.lineIntersection(a+c,b+d,a,b+d)),e.push.apply(e,this.lineIntersection(a,b+d,a,b)),e},this.boundingBoxIntersection=function(a){return this.boxIntersection(a.x,a.y,a.w,a.h)}},Arc:function(a){var c=(b.Segments.AbstractSegment.apply(this,arguments),function(b,c){return d.theta([a.cx,a.cy],[b,c])}),e=function(a,b){if(a.anticlockwise){var c=a.startAnglea-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1===b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||f!==1/0&&f!==-(1/0)||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=c/h*2*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}];b.Segments.AbstractSegment.apply(this,arguments);this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds},this.findClosestPointOnPath=function(b,c){var d=a.jsBezier.nearestPointOnCurve({x:b,y:c},this.curve);return{d:Math.sqrt(Math.pow(d.point.x-b,2)+Math.pow(d.point.y-c,2)),x:d.point.x,y:d.point.y,l:d.location,s:this}},this.lineIntersection=function(b,c,d,e){return a.jsBezier.lineIntersection(b,c,d,e,this.curve)}}},b.SegmentRenderer={getPath:function(a,b){return{Straight:function(b){var c=a.getCoordinates();return(b?"M "+c.x1+" "+c.y1+" ":"")+"L "+c.x2+" "+c.y2},Bezier:function(b){var c=a.params;return(b?"M "+c.x2+" "+c.y2+" ":"")+"C "+c.cp2x+" "+c.cp2y+" "+c.cp1x+" "+c.cp1y+" "+c.x1+" "+c.y1},Arc:function(b){var c=a.params,d=a.sweep>Math.PI?1:0,e=a.anticlockwise?0:1;return(b?"M"+a.x1+" "+a.y1+" ":"")+"A "+a.radius+" "+c.r+" 0 "+d+","+e+" "+a.x2+" "+a.y2}}[a.type](b)}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-(1/0),maxY:-(1/0)}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=null;this.getPathData=function(){for(var a="",c=0;c0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1===a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},t=function(a,c,d){if(d.x1!==d.x2||d.y1!==d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},u=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1===w,perpendicular:0===w,orthogonal:1===w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v],stubs:[k,l]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x};this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)};return this.pointOnPath=function(a,b){var c=s(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=s(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=s(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q=v.call(this,a),u(),this._compute(q,a),this.x=q.points[0],this.y=q.points[1],this.w=q.points[2],this.h=q.points[3],this.segment=q.segment,r()},{addSegment:t,prepareCompute:v,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(a,b,c,d){var e=this._compute.apply(this,arguments);return this.x=e[0],this.y=e[1],this.w=e[2],this.h=e[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,e};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c,d){this.radius=c.radius||this.radius;var e=a[0]-this.radius,f=a[1]-this.radius,g=2*this.radius,h=2*this.radius;if(c.stroke){var i=c.strokeWidth||1;e-=i,f-=i,g+=2*i,h+=2*i}return[e,f,g,h,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle";b.Endpoints.AbstractEndpoint.apply(this,arguments);a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c,d){var e=c.width||this.width,f=c.height||this.height,g=a[0]-e/2,h=a[1]-f/2;return[g,h,e,f]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var f=function(a){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(f,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",f.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,g=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor===String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(g,e),this._compute=function(a,b,c,d){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=b.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(a,b,d){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var e=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,f=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,e,f,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[f,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments);this.type="Blank",f.apply(this,arguments),this._compute=function(a,b,c,d){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=b.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(a,b){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,f],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments);var c=this;a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,d,e){var f=d.width||c.width,g=d.height||c.height,h=a[0]-f/2,i=a[1]-g/2;return[h,i,f,g]}};var g=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation,this.visible=a.visible!==!1};g.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(a,b){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){ +return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",g.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{};var e=this;this.length=a.length||20,this.width=a.width||20,this.id=a.id;var f=(a.direction||1)<0?-1:1,h=a.paintStyle||{"stroke-width":1},i=a.foldback||.623;this.computeMaxSize=function(){return 1.5*e.width},this.elementCreated=function(c,d){if(this.path=c,a.events)for(var e in a.events)b.on(c,e,a.events[e])},this.draw=function(a,b){var e,g,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;e=a.pointAlongPathFrom(n,m,!1),g=a.pointAlongPathFrom(n,m-f*this.length/2,!1),j=d.pointOnLine(e,g,this.length)}else if(1===this.loc){if(e=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(e,g,this.length),-1===f){var o=j;j=e,e=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),g=a.pointAlongPathFrom(this.loc,this.length),e=d.pointOnLine(j,g,this.length),-1===f){var p=j;j=e,e=p}}else e=a.pointAlongPathFrom(this.loc,f*this.length/2),g=a.pointOnPath(this.loc),j=d.pointOnLine(e,g,this.length);k=d.perpendicularLineTo(e,j,this.width),l=d.pointOnLine(e,j,i*this.length);var q={hxy:e,tail:k,cxy:l},r=h.stroke||b.stroke,s=h.fill||b.stroke,t=h.strokeWidth||b.strokeWidth;return{component:a,d:q,"stroke-width":t,stroke:r,fill:s,minX:Math.min(e.x,k[0].x,k[1].x),maxX:Math.max(e.x,k[0].x,k[1].x),minY:Math.min(e.y,k[0].y,k[1].y),maxY:Math.max(e.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,g,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback},cleanup:function(){this.path&&this.canvas&&this.canvas.removeChild(this.path)}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=b.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var h=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},i=function(a){b.jsPlumbUIComponent.apply(this,arguments),g.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var c=this._jsPlumb.div=b.getElement(this._jsPlumb.create(this._jsPlumb.component));c.style.position="absolute",jsPlumb.addClass(c,this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:"")),this._jsPlumb.instance.appendElement(c),this._jsPlumb.instance.getId(c),this.canvas=c;var d="translate(-50%, -50%)";c.style.webkitTransform=d,c.style.mozTransform=d,c.style.msTransform=d,c.style.oTransform=d,c.style.transform=d,c._jsPlumb=this,a.visible===!1&&(c.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=h(this);if(null!=e&&2===e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,i=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),i=!0),f=a.pointOnPath(g,i)}else{var j=this.loc.constructor===Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(i,[b.jsPlumbUIComponent,g],{getDimensions:function(){return[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(h(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a,b){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div),this.detached=!1},computeMaxSize:function(){var a=h(this);return Math.max(a[0],a[1])},paint:function(a,b){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(a){this.type="Custom",i.apply(this,arguments)},c.extend(b.Overlays.Custom,i),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.strokeWidth=5,this.type="GuideLines",g.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b,c){var e=b.pointAlongPathFrom(a.loc,a.length/2),f=b.pointOnPath(a.loc),g=d.pointOnLine(e,f,a.length),h=d.perpendicularLineTo(e,g,40),i=d.perpendicularLineTo(g,e,20);return{connector:b,head:e,tail:g,headLine:i,tailLine:h,minX:Math.min(e.x,g.x,i[0].x,i[1].x),minY:Math.min(e.y,g.y,i[0].y,i[1].y),maxX:Math.max(e.x,g.x,i[0].x,i[1].x),maxY:Math.max(e.y,g.y,i[0].y,i[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle;this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return b.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fill&&(d.style.background=this.labelStyle.fill),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),i.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
"))},updateFrom:function(a){null!=a.label&&this.setLabel(a.label)}})}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumbUtil,c=a.jsPlumbInstance,d="jtk-group-collapsed",e="jtk-group-expanded",f="[jtk-group-content]",g="elementDraggable",h="stop",i="revert",j="_groupManager",k="_jsPlumbGroup",l="_jsPlumbGroupDrag",m="group:addMember",n="group:removeMember",o="group:add",p="group:remove",q="group:expand",r="group:collapse",s="groupDragStop",t="connectionMoved",u="internal.connectionDetached",v="removeAll",w="orphanAll",x="show",y="hide",z=function(a){function c(a){delete a.proxies;var c,d=i[a.id];null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete i[a.id]),d=j[a.id],null!=d&&(c=function(b){return b.id===a.id},b.removeWithFunction(d.connections.source,c),b.removeWithFunction(d.connections.target,c),delete j[a.id])}function f(b,c){for(var d=b.getMembers(),e=0;e0&&h0&&j0?a[0]:u},w=d.ghost===!0,x=w||d.constrain===!0,y=d.revert!==!1,z=d.orphan===!0,A=d.prune===!0,B=d.dropOverride===!0,C=d.proxied!==!1,D=[];if(this.connections={source:[],target:[],internal:[]},this.getAnchor=function(a,b){return d.anchor||"Continuous"},this.getEndpoint=function(a,b){return d.endpoint||["Dot",{radius:10}]},this.collapsed=!1,d.draggable!==!1){var E={stop:function(a){c.fire(s,jsPlumb.extend(a,{group:t}))},scope:l};d.dragOptions&&a.jsPlumb.extend(E,d.dragOptions),c.draggable(d.el,E)}d.droppable!==!1&&c.droppable(d.el,{drop:function(a){var b=a.drag.el;if(!b._isJsPlumbGroup){var d=b._jsPlumbGroup;if(d!==t){if(null!=d&&d.overrideDrop(b,t))return;c.getGroupManager().addToGroup(t,b,!1)}}}});var F=function(a,b){for(var c=null==a.nodeType?a:[a],d=0;dd;d++){var f=D[0];t.remove(f,a,b,!0),c.remove(f,!0)}D.length=0,c.getGroupManager().updateConnectionsForGroup(t)},this.orphanAll=function(){for(var a={},b=0;ba?-1:0===a?0:1}),n=function(a){return[m(a[2]-a[0]),m(a[3]-a[1])]},o=function(a,b,c,d){if(j!==b||k!==c){var e=null==j?d.sx:j,f=null==k?d.sy:k,g=e===b?"v":"h";j=b,k=c,a.push([e,f,b,c,g])}},p=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},q=function(a){var b=[];return b.push.apply(b,a),b},r=function(a,b,c){for(var f,h,i,j=null,k=0;k0&&j[4]!==f[4]){var m=Math.min(p(j),p(f)),o=Math.min(l,m/2);j[2]-=h[0]*o,j[3]-=h[1]*o,f[0]+=i[0]*o,f[1]+=i[1]*o;var r=h[1]===i[0]&&1===i[0]||h[1]===i[0]&&0===i[0]&&h[0]!==i[1]||h[1]===i[0]&&-1===i[0],s=f[1]>j[3]?1:-1,t=f[0]>j[2]?1:-1,u=s===t,v=u&&r||!u&&!r?f[0]:j[2],w=u&&r||!u&&!r?j[3]:f[1];g.addSegment(a,d,{x1:j[0],y1:j[1],x2:j[2],y2:j[3]}),g.addSegment(a,e,{r:o,x1:j[2],y1:j[3],x2:f[0],y2:f[1],cx:v,cy:w,ac:r})}else{var x=j[2]===j[0]?0:j[2]>j[0]?c.lw/2:-(c.lw/2),y=j[3]===j[1]?0:j[3]>j[1]?c.lw/2:-(c.lw/2);g.addSegment(a,d,{x1:j[0]-x,y1:j[1]-y,x2:j[2]+x,y2:j[3]+y})}j=f}null!=f&&g.addSegment(a,d,{x1:f[0],y1:f[1],x2:f[2],y2:f[3]})};this._compute=function(a,b){c=[],j=null,k=null,f=null;var d=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},e={perpendicular:d,orthogonal:d,opposite:function(b){var c=a,d="x"===b?0:1,e={x:function(){return 1===c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1===c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1===c.so[d]&&(c.startStubYj[b][0],p=e[b][m][0],q=e[b][m][1],r=d[b][m][n];return c.segment===r[3]||c.segment===r[2]&&o?f[b]:c.segment===r[2]&&p>q?g[b]:c.segment===r[2]&&q>=p||c.segment===r[1]&&!o?i[b]:c.segment===r[0]||c.segment===r[1]&&o?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1===g.so[0]?Math.min(c,e):Math.max(c,e),y:-1===g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,e,f){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],k=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var l=e+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+g.maxStub;return{x:[[d,l],[f,l]],y:[[l,d],[l,f]]}[c]}return!k||1===h.so[m]&&d>f||-1===h.so[m]&&f>d?{x:[[d,v],[f,v]],y:[[u,d],[u,f]]}[c]:1===h.so[m]&&f>d||-1===h.so[m]&&d>f?{x:[[u,h.sy],[u,h.ty]],y:[[h.sx,v],[h.tx,v]]}[c]:void 0}},y=x[a.anchorOrientation](a.sourceAxis,p,q,s,t);if(y)for(var z=0;z=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0},f=function(a){a=a||{},this.type="StateMachine";var c,f=b.Connectors.AbstractBezierConnector.apply(this,arguments),g=a.curviness||10,h=a.margin||5,i=a.proximityLimit||80;a.orientation&&"clockwise"===a.orientation;this._computeBezier=function(a,b,j,k,l,m){var n=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=b.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var c=this,d=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(d,e,f){var g=c.getSegments(),h="",i=[0,0];if(f.xmin<0&&(i[0]=-f.xmin),f.ymin<0&&(i[1]=-f.ymin),g.length>0){h=c.getPathData();var j={d:h,transform:"translate("+i[0]+","+i[1]+")","pointer-events":a["pointer-events"]||"visibleStroke"},k=null,l=[c.x,c.y,c.w,c.h];if(d.outlineStroke){var m=d.outlineWidth||1,n=d.strokeWidth+2*m;k=b.extend({},d),delete k.gradient,k.stroke=d.outlineStroke,k.strokeWidth=n,null==c.bgPath?(c.bgPath=t("path",j),b.addClass(c.bgPath,b.connectorOutlineClass),y(c.svg,c.bgPath,0)):s(c.bgPath,j),x(c.svg,c.bgPath,k,l,c)}null==c.path?(c.path=t("path",j),y(c.svg,c.path,d.outlineStroke?1:0)):s(c.path,j),x(c.svg,c.path,d,l,c)}}},c.extend(b.ConnectorRenderers.svg,z);var A=b.SvgEndpoint=function(a){var c=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);c.renderer.paint=function(a){var c=b.extend({},a);c.outlineStroke&&(c.stroke=c.outlineStroke),null==this.node?(this.node=this.makeNode(c),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,c,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(a){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1;this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.elementCreated&&this.elementCreated(this.path,a.component),this.canvas=a.component.svg);var e=c&&1===c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.stroke?a.stroke:null,fill:a.fill?a.fill:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y; +};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(a,b){this.path&&b.canvas&&b.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]),b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call("undefined"!=typeof window?window:this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=a.Katavorio,e=a.Biltong,f=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c},g=function(a,c){c=c||"main";var f="_katavorio_"+c,g=a[f],h=a.getEventManager();return g||(g=new d({bind:h.on,unbind:h.off,getSize:b.getSize,getConstrainingRectangle:function(a){return[a.parentNode.scrollWidth,a.parentNode.scrollHeight]},getPosition:function(b,c){var d=a.getOffset(b,c,b._katavorioDrag?b.offsetParent:null);return[d.left,d.top]},setPosition:function(a,b){a.style.left=b[0]+"px",a.style.top=b[1]+"px"},addClass:b.addClass,removeClass:b.removeClass,intersects:e.intersects,indexOf:function(a,b){return a.indexOf(b)},scope:a.getDefaultScope(),css:{noSelect:a.dragSelectClass,droppable:"jtk-droppable",draggable:"jtk-draggable",drag:"jtk-drag",selected:"jtk-drag-selected",active:"jtk-drag-active",hover:"jtk-drag-hover",ghostProxy:"jtk-ghost-proxy"}}),g.setZoom(a.getZoom()),a[f]=g,a.bind("zoom",g.setZoom)),g},h=function(a){var b=a.el._jsPlumbDragOptions,c=!0;return b.canDrag&&(c=b.canDrag()),c&&(this.setHoverSuspended(!0),this.select({source:a.el}).addClass(this.elementDraggingClass+" "+this.sourceElementDraggingClass,!0),this.select({target:a.el}).addClass(this.elementDraggingClass+" "+this.targetElementDraggingClass,!0),this.setConnectionBeingDragged(!0)),c},i=function(a){var b=this.getUIPosition(arguments,this.getZoom());if(null!=b){var c=a.el._jsPlumbDragOptions;this.draw(a.el,b,null,!0),c._dragging&&this.addClass(a.el,"jtk-dragged"),c._dragging=!0}},j=function(a){for(var b,c=a.selection,d=function(a){null!=a[1]&&(b=this.getUIPosition([{el:a[2].el,pos:[a[1].left,a[1].top]}]),this.draw(a[2].el,b)),delete a[0]._jsPlumbDragOptions._dragging,this.removeClass(a[0],"jtk-dragged"),this.select({source:a[2].el}).removeClass(this.elementDraggingClass+" "+this.sourceElementDraggingClass,!0),this.select({target:a[2].el}).removeClass(this.elementDraggingClass+" "+this.targetElementDraggingClass,!0),this.getDragManager().dragEnded(a[2].el)}.bind(this),e=0;e0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},r=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h,i=a.getId(g);b[i]||(b[i]=g,c.push(g),d[i]={});var j=function(b){if(b)for(var c=0;c0){h||(h=a.getOffset(g));var m=a.getOffset(k);d[i][l]={id:l,offset:{left:m.left-h.left,top:m.top-h.top}},f[l]=i}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b,c){if(null!=b){c=c||{};var e,g=jsPlumb.getElement(b),h=a.getId(g),i=d[h];if(i)for(var j in i)if(i.hasOwnProperty(j)){var k=jsPlumb.getElement(j),l=c[j]||a.getOffset(k);if(null==k.offsetParent&&null!=d[h][j])continue;e||(e=a.getOffset(g)),d[h][j]={id:j,offset:{left:l.left-e.left,top:l.top-e.top}},f[j]=h}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!==h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){if(null!=b.offsetParent){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)}},this.setParent=function(b,c,e,g,h){var i=f[c];d[g]||(d[g]={});var j=a.getOffset(e),k=h||a.getOffset(b);i&&d[i]&&delete d[i][c],d[g][c]={id:c,offset:{left:k.left-j.left,top:k.top-j.top}},f[c]=g},this.clearParent=function(a,b){var c=f[b];c&&(delete d[c][b],delete f[b])},this.revalidateParent=function(b,c,d){var e=f[c];if(e){var g={};g[c]=d,this.updateOffsets(e,g),a.revalidate(e)}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},s=function(a,b,d){b=c.fastTrim(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b;try{var e=a.classList;if(null!=e){for(;e.length>0;)e.remove(e.item(0));for(var f=0;f0||a.scrollLeft>0)&&(d.left-=a.scrollLeft,d.top-=a.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent===c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!==g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight},getRenderMode:function(){return"svg"},draggable:function(a,b){var d;return a=c.isArray(a)||null!=a.length&&!c.isString(a)?a:[a],Array.prototype.slice.call(a).forEach(function(a){d=this.info(a),d.el&&this._initDraggableIfNecessary(d.el,!0,b,d.id,!0)}.bind(this)),this},initDraggable:function(a,b,c){g(this,c).draggable(a,b),a._jsPlumbDragOptions=b},destroyDraggable:function(a,b){g(this,b).destroyDraggable(a),delete a._jsPlumbDragOptions},unbindDraggable:function(a,b,c,d){g(this,d).destroyDraggable(a,b,c)},setDraggable:function(a,b){return jsPlumb.each(a,function(a){this.isDragSupported(a)&&(this._draggableStates[this.getAttribute(a,"id")]=b,this.setElementDraggable(a,b))}.bind(this))},_draggableStates:{},toggleDraggable:function(a){var b;return jsPlumb.each(a,function(a){var c=this.getAttribute(a,"id");return b=null==this._draggableStates[c]?!1:this._draggableStates[c],b=!b,this._draggableStates[c]=b,this.setDraggable(a,b),b}.bind(this)),b},_initDraggableIfNecessary:function(a,b,d,e,f){if(!jsPlumb.headless){var g=null==b?!1:b;if(g&&jsPlumb.isDragSupported(a,this)){var k=d||this.Defaults.DragOptions;if(k=jsPlumb.extend({},k),jsPlumb.isAlreadyDraggable(a,this))d.force&&this.initDraggable(a,k);else{var l=jsPlumb.dragEvents.drag,m=jsPlumb.dragEvents.stop,n=jsPlumb.dragEvents.start;this.manage(e,a),k[n]=c.wrap(k[n],h.bind(this)),k[l]=c.wrap(k[l],i.bind(this)),k[m]=c.wrap(k[m],j.bind(this));var o=this.getId(a);this._draggableStates[o]=!0;var p=this._draggableStates[o];k.disabled=null==p?!1:!p,this.initDraggable(a,k),this.getDragManager().register(a),f&&this.fire("elementDraggable",{el:a,options:k})}}}},animationSupported:!0,getElement:function(a){return null==a?null:(a="string"==typeof a?a:null!=a.length&&null==a.enctype?a[0]:a,"string"==typeof a?document.getElementById(a):a)},removeElement:function(a){g(this).elementRemoved(a),this.getEventManager().remove(a)},doAnimate:function(a,c,d){d=d||{};var e=this.getOffset(a),f=k(e,c),g=f[0]-e.left,h=f[1]-e.top,i=d.duration||250,j=15,l=i/j,m=j/i*g,n=j/i*h,o=0,p=setInterval(function(){b.setPosition(a,{left:e.left+m*(o+1),top:e.top+n*(o+1)}),null!=d.step&&d.step(o,Math.ceil(l)),o++,o>=l&&(window.clearInterval(p),null!=d.complete&&d.complete())},j)},destroyDroppable:function(a,b){g(this,b).destroyDroppable(a)},unbindDroppable:function(a,b,c,d){g(this,d).destroyDroppable(a,b,c)},droppable:function(a,b){a=c.isArray(a)||null!=a.length&&!c.isString(a)?a:[a];var d;return b=b||{},b.allowLoopback=!1,Array.prototype.slice.call(a).forEach(function(a){d=this.info(a),d.el&&this.initDroppable(d.el,b)}.bind(this)),this},initDroppable:function(a,b,c){g(this,c).droppable(a,b)},isAlreadyDraggable:function(a){return null!=a._katavorioDrag},isDragSupported:function(a,b){return!0},isDropSupported:function(a,b){return!0},isElementDraggable:function(a){return a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.isEnabled()},getDragObject:function(a){return a[0].drag.getDragElement()},getDragScope:function(a){return a._katavorioDrag&&a._katavorioDrag.scopes.join(" ")||""},getDropEvent:function(a){return a[0].e},getUIPosition:function(a,b){var c=a[0].el;if(null==c.offsetParent)return null;var d=a[0].finalPos||a[0].pos,e={left:d[0],top:d[1]};if(c._katavorioDrag&&c.offsetParent!==this.getContainer()){var f=this.getOffset(c.offsetParent);e.left+=f.left,e.top+=f.top}return e},setDragFilter:function(a,b,c){a._katavorioDrag&&a._katavorioDrag.setFilter(b,c)},setElementDraggable:function(a,c){a=b.getElement(a),a._katavorioDrag&&a._katavorioDrag.setEnabled(c)},setDragScope:function(a,b){a._katavorioDrag&&a._katavorioDrag.k.setDragScope(a,b)},setDropScope:function(a,b){a._katavorioDrop&&a._katavorioDrop.length>0&&a._katavorioDrop[0].k.setDropScope(a,b)},addToPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.addToPosse.apply(e,a)})},setPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.setPosse.apply(e,a)})},removeFromPosse:function(a,c){var d=Array.prototype.slice.call(arguments,1),e=g(this);b.each(a,function(a){a=[b.getElement(a)],a.push.apply(a,d),e.removeFromPosse.apply(e,a)})},removeFromAllPosses:function(a){var c=g(this);b.each(a,function(a){c.removeFromAllPosses(b.getElement(a))})},setPosseState:function(a,c,d){var e=g(this);b.each(a,function(a){e.setPosseState(b.getElement(a),c,d)})},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete",beforeStart:"beforeStart"},animEvents:{step:"step",complete:"complete"},stopDrag:function(a){a._katavorioDrag&&a._katavorioDrag.abort()},addToDragSelection:function(a){g(this).select(a)},removeFromDragSelection:function(a){g(this).deselect(a)},clearDragSelection:function(){g(this).deselectAll()},trigger:function(a,b,c,d){this.getEventManager().trigger(a,b,c,d)},doReset:function(){for(var a in this)0===a.indexOf("_katavorio_")&&this[a].reset()},getEventManager:function(){return f(this)},on:function(a,b,c){return this.getEventManager().on.apply(this,arguments),this},off:function(a,b,c){return this.getEventManager().off.apply(this,arguments),this}});var v=function(a){var b=function(){/complete|loaded|interactive/.test(document.readyState)&&"undefined"!=typeof document.body&&null!=document.body?a():setTimeout(b,9)};b()};v(b.init)}.call("undefined"!=typeof window?window:this); /*! * System Runtime * diff --git a/designer/scripts/diagram.js b/designer/scripts/diagram.js index 399c374..ff332c3 100644 --- a/designer/scripts/diagram.js +++ b/designer/scripts/diagram.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"diagram","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[{"name":"dotFile","description":"","type":"any","mandatory":false,"default":""},{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + library.source().version + '

' +\n '
';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

' + system.name + '

' +\n '

v' + system.version + '

' +\n '
';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + extension.source().version + '

' +\n '
';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

No extension found

';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + extension.source().version + '

' +\n '
';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

No extension found

';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

' +\n '

v' + system.version + '

' +\n '
';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

No extension found

';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Schema ' + schemas[id]._name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Model ' + models[id]._name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Type ' + types[id].name + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

';\n } else { \n link = link + '

Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

';\n }\n \n link = link + '

...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

Component ' + components[collection][id]._id + ' ' + numberResult.html + '

' +\n '

...' + showResult(toSearch, index, value) + '...

' +\n '
';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

There is no result for your search

'\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

Schema ' + schemas[id]._name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

Model ' + models[id]._name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

Type ' + types[id].name + '

' +\n '
';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

Behavior ' + systemName + '.' + behaviors[id].state + '

';\n } else { \n link = link + '

Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

';\n }\n '
';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

Component ' + components[collection][id]._id + '

' +\n '
';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

There is no result

');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"f14706139781d16b":{"_id":"f14706139781d16b","component":"a1e94f187c412b2a","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n this.require('viz').render('', this.require('state').menu());\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n // get parameters\n systemId = document.location.href.split('#')[1].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n \n if (system) {\n this.require('factory').create(system);\n }\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // extensions\n this.installExtensions();\n \n // title\n if (system) {\n document.title = 'diagrams · system ' + system.name;\n } else {\n document.title = 'diagrams';\n }\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"a1c33618ac01371c","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShortcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false},"z1d2f51cbab10c86":{"_id":"z1d2f51cbab10c86","component":"q189c51d320139d0","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/generate-a-diagram.html', '_blank', true);\t\n}","useCoreAPI":false,"core":false},"x1c18b145e6157d8":{"_id":"x1c18b145e6157d8","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"m12e321f21a15f05":{"_id":"m12e321f21a15f05","component":"_Channel","state":"$designerCreateSchema","action":"function $designerCreateSchema(id, schema) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"z101721b5941bf54":{"_id":"z101721b5941bf54","component":"_Channel","state":"$designerUpdateModel","action":"function $designerUpdateModel(id, model) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"l108ea1b11c10e8b":{"_id":"l108ea1b11c10e8b","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"b13285192b811ad1":{"_id":"b13285192b811ad1","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"u1c69b124bc1ac09":{"_id":"u1c69b124bc1ac09","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"d185231c5af12d54":{"_id":"d185231c5af12d54","component":"q1da4e1ca6710ca2","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoomin').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var svg = document.getElementsByTagName('svg')[0];\n var matrixGroup = '';\n \n if (svg) {\n matrixGroup = svg.getElementById('graph0');\t\n \n function zoom(scale) {\n var previousScale = matrixGroup.getAttribute('transform').split(')')[0];\n var transformInfo = matrixGroup.getAttribute('transform').replace(previousScale + ')', '');\n \n matrixGroup.setAttribute('transform', 'scale(' + scale + ') ' + transformInfo);\n }\n \n this.require('viz').zoom(this.require('viz').zoom() + 0.1);\n zoom(this.require('viz').zoom());\n \n this.require('message').success('Zoom x' + this.require('viz').zoom().toString().substring(0, 3) + ' applied.');\n } else {\n this.require('message').warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"l19d291b99311024":{"_id":"l19d291b99311024","component":"p15e7513ed512f61","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoomout').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var svg = document.getElementsByTagName('svg')[0];\n var matrixGroup = '';\n \n if (svg) {\n matrixGroup = svg.getElementById('graph0');\t\n \n function zoom(scale) {\n var previousScale = matrixGroup.getAttribute('transform').split(')')[0];\n var transformInfo = matrixGroup.getAttribute('transform').replace(previousScale + ')', '');\n \n matrixGroup.setAttribute('transform', 'scale(' + scale + ') ' + transformInfo);\n }\n \n this.require('viz').zoom(this.require('viz').zoom() - 0.1);\n zoom(this.require('viz').zoom());\t\n \n this.require('message').success('Zoom x' + this.require('viz').zoom().toString().substring(0, 3) + ' applied.');\n } else {\n this.require('message').warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"u1695c1c8551203c":{"_id":"u1695c1c8551203c","component":"Diagram","state":"render","action":"function render(dotFile, diagramType) { \n var dotGraph = '',\n storeConfig = null;\n\n switch(true) {\n case dotFile !== '':\n dotGraph = dotFile;\n document.title = 'diagrams';\n break;\n case this.data() !== '':\n dotGraph = this.data();\n document.title = 'diagrams';\n break;\n case this.require('factory').system() !== undefined:\n dotGraph = this.require('export').toGraphviz(diagramType);\n break;\n default: \n document.title = 'diagrams';\n $('#designer-diagram').empty();\n this.require('message-help').render();\n return;\n }\n \n if (!this.ref()) {\n this.ref(new Viz());\n }\n\n this.ref().renderSVGElement(dotGraph)\n .then(function(element) {\n var elt = document.getElementById('designer-diagram');\n\n $('#designer-diagram').empty();\n elt.appendChild(element);\n \n var svg = document.getElementsByTagName('svg')[0];\n \n // set width and heigth\n svg.setAttribute('width', ($(document).width() - 50) + 'px');\n svg.setAttribute('height', ($(document).height() - 50) + 'px');\n \n // svg event\n svg.addEventListener('mousedown', startDrag, false);\n svg.addEventListener('mousemove', drag, false);\n svg.addEventListener('mouseup', endDrag, false);\n\n var selectedElement, dragX, dragY;\n var reTranslate = /translate\\s*\\(([-\\+\\d\\.\\s,e]+)\\)/gi;\n\n function startDrag(evt) {\n var screenMatrix = svg.getScreenCTM();\n selectedElement = document.getElementById('graph0');\n dragX = evt.clientX / screenMatrix.a;\n dragY = evt.clientY / screenMatrix.d;\n\n var transform = selectedElement.getAttribute('transform');\n var translate = reTranslate.exec(transform);\n if (translate) {\n var digits = translate[1].split(/\\s*[,\\s]+/);\n dragX -= parseFloat(digits[0] || 0);\n dragY -= parseFloat(digits[1] || 0);\n } else {\n translate = 'translate(0, 0)';\n if (transform) {\n selectedElement.setAttribute('transform', translate + transform);\n } else {\n selectedElement.setAttribute('transform', translate);\n }\n }\n }\n\n function drag(evt) {\n if (selectedElement) {\n var screenMatrix = svg.getScreenCTM();\n var x = evt.clientX / screenMatrix.a - dragX;\n var y = evt.clientY / screenMatrix.d - dragY;\n\n var transform = selectedElement.getAttribute('transform');\n transform = transform.replace(reTranslate, 'translate(' + x + ' ' + y + ')');\n selectedElement.setAttribute('transform', transform);\n }\n }\n\n function endDrag(evt) {\n if (selectedElement) {\n var screenMatrix = svg.getScreenCTM();\n var x = evt.clientX / screenMatrix.a - dragX;\n var y = evt.clientY / screenMatrix.d - dragY;\n\n var transform = selectedElement.getAttribute('transform');\n transform = transform.replace(reTranslate, 'translate(' + x + ' ' + y + ')');\n selectedElement.setAttribute('transform', transform);\n }\n selectedElement = false;\n }\n \n if (runtime.require('viz').zoom() === 1) {\n runtime.require('message').success('Diagram generated.');\n }\n })\n .catch(error => {\n if (!runtime.require('viz').ref()) {\n runtime.require('viz').ref(new Viz());\n }\n\n runtime.require('message').danger(error.toString());\n });\n}","useCoreAPI":false,"core":false},"j1685617835183b2":{"_id":"j1685617835183b2","component":"c1b63f13c911fcc8","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoominit').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var data = this.require('viz').data();\n \n if (this.require('factory').system() || data) {\n\t this.require('viz').zoom(1);\n\t this.require('viz').render('', this.require('state').menu());\n } else {\n message.warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"r1484a1f32d17210":{"_id":"r1484a1f32d17210","component":"q16e321bb2c15a27","state":"click","action":"function click() { \n $('#designer-toolbar-item-export-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var data = this.require('viz').data();\n\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system() || data) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n \n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n textToWrite = '' + $('#designer-diagram').html();\n fileNameToSaveAs = this.require('factory').system().name() + '.svg';\n } else {\n textToWrite = '' + $('#designer-diagram').html();\n fileNameToSaveAs = 'diagram.svg';\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n downloadLink.download = fileNameToSaveAs;\n\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n }\n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n message.success('Exportation is done.');\n } else {\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"i1cfbb13c0211eef":{"_id":"i1cfbb13c0211eef","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var dotFile = '';\n reader.onload = function (event) {\n dotFile += event.target.result;\n };\n reader.onloadend = function () {\n var DialogDropDiagram = that.require('DialogDropDiagram');\n \n DialogDropDiagram = new DialogDropDiagram({\n 'title': 'A diagram has been found',\n 'message': 'You can view the diagram.'\n });\n \n DialogDropDiagram.data(dotFile);\n DialogDropDiagram.show();\n };\n if (files[0] && files[0].name && files[0].name.indexOf('.gv') !== -1) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\t\n}","useCoreAPI":false,"core":false},"f14c33175231efa3":{"_id":"f14c33175231efa3","component":"t19b191613819247","state":"click","action":"function click() { \n this.require('viz').render('', 'class');\t\n}","useCoreAPI":false,"core":false},"x176de1c48512a3c":{"_id":"x176de1c48512a3c","component":"1f1781882618106","state":"click","action":"function click() { \n\tthis.require('viz').render('', 'component');\t\n}","useCoreAPI":false,"core":false},"p1cd061f71a153f6":{"_id":"p1cd061f71a153f6","component":"f19f7e1cda81cf2a","state":"click","action":"function click() { \n\tthis.require('viz').render('', 'graph');\t\n}","useCoreAPI":false,"core":false},"w192051618110afb":{"_id":"w192051618110afb","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\t\n}","useCoreAPI":false,"core":false},"a133fb118891e10e":{"_id":"a133fb118891e10e","component":"_Channel","state":"$designerCreateComponent","action":"function $designerCreateComponent(collection, component) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"j1c338172a21924e":{"_id":"j1c338172a21924e","component":"_Channel","state":"$designerDeleteComponent","action":"function $designerDeleteComponent(id, collection) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"u147cf1987415896":{"_id":"u147cf1987415896","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n if (system.components && system.components[collection] && system.components[collection][id]) {\n system.components[collection][id] = component;\n }\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\t\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{"viz":{"_id":"viz","ref":"","zoom":1}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on the\n Quick Start page or\n at this short video.\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"diagram"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"diagram"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"component","html":"menu-item-component-diagram.html","position":20,"type":"diagram","platform":"all"},"t19b191613819247":{"_id":"t19b191613819247","html":"menu-item-class-diagram.html","name":"class","platform":"all","position":10,"type":"diagram"},"f19f7e1cda81cf2a":{"_id":"f19f7e1cda81cf2a","html":"menu-item-graph-diagram.html","name":"graph","platform":"all","position":30,"type":"diagram"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"a1e94f187c412b2a":{"_id":"a1e94f187c412b2a","html":"toolbar-item-copyright.html","position":90,"type":"diagram","platform":"all"},"q189c51d320139d0":{"_id":"q189c51d320139d0","html":"toolbar-item-help.html","platform":"all","position":80,"type":"diagram"},"p15e7513ed512f61":{"_id":"p15e7513ed512f61","html":"toolbar-item-zoomout.html","platform":"all","position":20,"type":"diagram"},"q1da4e1ca6710ca2":{"_id":"q1da4e1ca6710ca2","html":"toolbar-item-zoomin.html","platform":"all","position":30,"type":"diagram"},"c1b63f13c911fcc8":{"_id":"c1b63f13c911fcc8","html":"toolbar-item-zoominit.html","platform":"all","position":10,"type":"diagram"},"q16e321bb2c15a27":{"_id":"q16e321bb2c15a27","html":"toolbar-item-export-diagram.html","platform":"all","position":40,"type":"diagram"}}},"_id":"a1c33618ac01371c"}); \ No newline at end of file +runtime.install({"name":"diagram","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[{"name":"dotFile","description":"","type":"any","mandatory":false,"default":""},{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"f14706139781d16b":{"_id":"f14706139781d16b","component":"a1e94f187c412b2a","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n this.require('viz').render('', this.require('state').menu());\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n // get parameters\n systemId = document.location.href.split('#')[1].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n \n if (system) {\n this.require('factory').create(system);\n }\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // extensions\n this.installExtensions();\n \n // title\n if (system) {\n document.title = 'diagrams · system ' + system.name;\n } else {\n document.title = 'diagrams';\n }\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"a1c33618ac01371c","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShortcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false},"z1d2f51cbab10c86":{"_id":"z1d2f51cbab10c86","component":"q189c51d320139d0","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/generate-a-diagram.html', '_blank', true);\t\n}","useCoreAPI":false,"core":false},"x1c18b145e6157d8":{"_id":"x1c18b145e6157d8","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"m12e321f21a15f05":{"_id":"m12e321f21a15f05","component":"_Channel","state":"$designerCreateSchema","action":"function $designerCreateSchema(id, schema) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"z101721b5941bf54":{"_id":"z101721b5941bf54","component":"_Channel","state":"$designerUpdateModel","action":"function $designerUpdateModel(id, model) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"l108ea1b11c10e8b":{"_id":"l108ea1b11c10e8b","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"b13285192b811ad1":{"_id":"b13285192b811ad1","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"u1c69b124bc1ac09":{"_id":"u1c69b124bc1ac09","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"d185231c5af12d54":{"_id":"d185231c5af12d54","component":"q1da4e1ca6710ca2","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoomin').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var svg = document.getElementsByTagName('svg')[0];\n var matrixGroup = '';\n \n if (svg) {\n matrixGroup = svg.getElementById('graph0');\t\n \n function zoom(scale) {\n var previousScale = matrixGroup.getAttribute('transform').split(')')[0];\n var transformInfo = matrixGroup.getAttribute('transform').replace(previousScale + ')', '');\n \n matrixGroup.setAttribute('transform', 'scale(' + scale + ') ' + transformInfo);\n }\n \n this.require('viz').zoom(this.require('viz').zoom() + 0.1);\n zoom(this.require('viz').zoom());\n \n this.require('message').success('Zoom x' + this.require('viz').zoom().toString().substring(0, 3) + ' applied.');\n } else {\n this.require('message').warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"l19d291b99311024":{"_id":"l19d291b99311024","component":"p15e7513ed512f61","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoomout').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var svg = document.getElementsByTagName('svg')[0];\n var matrixGroup = '';\n \n if (svg) {\n matrixGroup = svg.getElementById('graph0');\t\n \n function zoom(scale) {\n var previousScale = matrixGroup.getAttribute('transform').split(')')[0];\n var transformInfo = matrixGroup.getAttribute('transform').replace(previousScale + ')', '');\n \n matrixGroup.setAttribute('transform', 'scale(' + scale + ') ' + transformInfo);\n }\n \n this.require('viz').zoom(this.require('viz').zoom() - 0.1);\n zoom(this.require('viz').zoom());\t\n \n this.require('message').success('Zoom x' + this.require('viz').zoom().toString().substring(0, 3) + ' applied.');\n } else {\n this.require('message').warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"u1695c1c8551203c":{"_id":"u1695c1c8551203c","component":"Diagram","state":"render","action":"function render(dotFile, diagramType) { \n var dotGraph = '',\n storeConfig = null;\n\n switch(true) {\n case dotFile !== '':\n dotGraph = dotFile;\n document.title = 'diagrams';\n break;\n case this.data() !== '':\n dotGraph = this.data();\n document.title = 'diagrams';\n break;\n case this.require('factory').system() !== undefined:\n dotGraph = this.require('export').toGraphviz(diagramType);\n break;\n default: \n document.title = 'diagrams';\n $('#designer-diagram').empty();\n this.require('message-help').render();\n return;\n }\n \n if (!this.ref()) {\n this.ref(new Viz());\n }\n\n this.ref().renderSVGElement(dotGraph)\n .then(function(element) {\n var elt = document.getElementById('designer-diagram');\n\n $('#designer-diagram').empty();\n elt.appendChild(element);\n \n var svg = document.getElementsByTagName('svg')[0];\n \n // set width and heigth\n svg.setAttribute('width', ($(document).width() - 50) + 'px');\n svg.setAttribute('height', ($(document).height() - 50) + 'px');\n \n // svg event\n svg.addEventListener('mousedown', startDrag, false);\n svg.addEventListener('mousemove', drag, false);\n svg.addEventListener('mouseup', endDrag, false);\n\n var selectedElement, dragX, dragY;\n var reTranslate = /translate\\s*\\(([-\\+\\d\\.\\s,e]+)\\)/gi;\n\n function startDrag(evt) {\n var screenMatrix = svg.getScreenCTM();\n selectedElement = document.getElementById('graph0');\n dragX = evt.clientX / screenMatrix.a;\n dragY = evt.clientY / screenMatrix.d;\n\n var transform = selectedElement.getAttribute('transform');\n var translate = reTranslate.exec(transform);\n if (translate) {\n var digits = translate[1].split(/\\s*[,\\s]+/);\n dragX -= parseFloat(digits[0] || 0);\n dragY -= parseFloat(digits[1] || 0);\n } else {\n translate = 'translate(0, 0)';\n if (transform) {\n selectedElement.setAttribute('transform', translate + transform);\n } else {\n selectedElement.setAttribute('transform', translate);\n }\n }\n }\n\n function drag(evt) {\n if (selectedElement) {\n var screenMatrix = svg.getScreenCTM();\n var x = evt.clientX / screenMatrix.a - dragX;\n var y = evt.clientY / screenMatrix.d - dragY;\n\n var transform = selectedElement.getAttribute('transform');\n transform = transform.replace(reTranslate, 'translate(' + x + ' ' + y + ')');\n selectedElement.setAttribute('transform', transform);\n }\n }\n\n function endDrag(evt) {\n if (selectedElement) {\n var screenMatrix = svg.getScreenCTM();\n var x = evt.clientX / screenMatrix.a - dragX;\n var y = evt.clientY / screenMatrix.d - dragY;\n\n var transform = selectedElement.getAttribute('transform');\n transform = transform.replace(reTranslate, 'translate(' + x + ' ' + y + ')');\n selectedElement.setAttribute('transform', transform);\n }\n selectedElement = false;\n }\n \n if (runtime.require('viz').zoom() === 1) {\n runtime.require('message').success('Diagram generated.');\n }\n })\n .catch(error => {\n if (!runtime.require('viz').ref()) {\n runtime.require('viz').ref(new Viz());\n }\n\n runtime.require('message').danger(error.toString());\n });\n}","useCoreAPI":false,"core":false},"j1685617835183b2":{"_id":"j1685617835183b2","component":"c1b63f13c911fcc8","state":"click","action":"function click() { \n $('#designer-toolbar-item-zoominit').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var data = this.require('viz').data();\n \n if (this.require('factory').system() || data) {\n\t this.require('viz').zoom(1);\n\t this.require('viz').render('', this.require('state').menu());\n } else {\n message.warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"r1484a1f32d17210":{"_id":"r1484a1f32d17210","component":"q16e321bb2c15a27","state":"click","action":"function click() { \n $('#designer-toolbar-item-export-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var data = this.require('viz').data();\n\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system() || data) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n \n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n textToWrite = '' + $('#designer-diagram').html();\n fileNameToSaveAs = this.require('factory').system().name() + '.svg';\n } else {\n textToWrite = '' + $('#designer-diagram').html();\n fileNameToSaveAs = 'diagram.svg';\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n downloadLink.download = fileNameToSaveAs;\n\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n }\n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n message.success('Exportation is done.');\n } else {\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no diagram.');\n }\n}","useCoreAPI":false,"core":false},"i1cfbb13c0211eef":{"_id":"i1cfbb13c0211eef","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var dotFile = '';\n reader.onload = function (event) {\n dotFile += event.target.result;\n };\n reader.onloadend = function () {\n var DialogDropDiagram = that.require('DialogDropDiagram');\n \n DialogDropDiagram = new DialogDropDiagram({\n 'title': 'A diagram has been found',\n 'message': 'You can view the diagram.'\n });\n \n DialogDropDiagram.data(dotFile);\n DialogDropDiagram.show();\n };\n if (files[0] && files[0].name && files[0].name.indexOf('.gv') !== -1) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\t\n}","useCoreAPI":false,"core":false},"f14c33175231efa3":{"_id":"f14c33175231efa3","component":"t19b191613819247","state":"click","action":"function click() { \n this.require('viz').render('', 'class');\t\n}","useCoreAPI":false,"core":false},"x176de1c48512a3c":{"_id":"x176de1c48512a3c","component":"1f1781882618106","state":"click","action":"function click() { \n\tthis.require('viz').render('', 'component');\t\n}","useCoreAPI":false,"core":false},"p1cd061f71a153f6":{"_id":"p1cd061f71a153f6","component":"f19f7e1cda81cf2a","state":"click","action":"function click() { \n\tthis.require('viz').render('', 'graph');\t\n}","useCoreAPI":false,"core":false},"w192051618110afb":{"_id":"w192051618110afb","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\t\n}","useCoreAPI":false,"core":false},"a133fb118891e10e":{"_id":"a133fb118891e10e","component":"_Channel","state":"$designerCreateComponent","action":"function $designerCreateComponent(collection, component) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"j1c338172a21924e":{"_id":"j1c338172a21924e","component":"_Channel","state":"$designerDeleteComponent","action":"function $designerDeleteComponent(id, collection) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"u147cf1987415896":{"_id":"u147cf1987415896","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n var systemId = this.require('factory').system().id();\n var system = this.require('storage').get(systemId);\n \n if (system.components && system.components[collection] && system.components[collection][id]) {\n system.components[collection][id] = component;\n }\n \n this.require('factory').create(system);\n this.require('workspace').render();\t\t\t\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{"viz":{"_id":"viz","ref":"","zoom":1}},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on the\n Quick Start page or\n at this short video.\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"diagram"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"diagram"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"component","html":"menu-item-component-diagram.html","position":20,"type":"diagram","platform":"all"},"t19b191613819247":{"_id":"t19b191613819247","html":"menu-item-class-diagram.html","name":"class","platform":"all","position":10,"type":"diagram"},"f19f7e1cda81cf2a":{"_id":"f19f7e1cda81cf2a","html":"menu-item-graph-diagram.html","name":"graph","platform":"all","position":30,"type":"diagram"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"a1e94f187c412b2a":{"_id":"a1e94f187c412b2a","html":"toolbar-item-copyright.html","position":90,"type":"diagram","platform":"all"},"q189c51d320139d0":{"_id":"q189c51d320139d0","html":"toolbar-item-help.html","platform":"all","position":80,"type":"diagram"},"p15e7513ed512f61":{"_id":"p15e7513ed512f61","html":"toolbar-item-zoomout.html","platform":"all","position":20,"type":"diagram"},"q1da4e1ca6710ca2":{"_id":"q1da4e1ca6710ca2","html":"toolbar-item-zoomin.html","platform":"all","position":30,"type":"diagram"},"c1b63f13c911fcc8":{"_id":"c1b63f13c911fcc8","html":"toolbar-item-zoominit.html","platform":"all","position":10,"type":"diagram"},"q16e321bb2c15a27":{"_id":"q16e321bb2c15a27","html":"toolbar-item-export-diagram.html","platform":"all","position":40,"type":"diagram"}}},"_id":"a1c33618ac01371c"}); \ No newline at end of file diff --git a/designer/scripts/editor-behavior.js b/designer/scripts/editor-behavior.js index 3179666..17f9a37 100644 --- a/designer/scripts/editor-behavior.js +++ b/designer/scripts/editor-behavior.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-behavior","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u165f215d0217974":{"_id":"u165f215d0217974","component":"1dbc513e0e11z15","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"f1846f199e41074c":{"_id":"f1846f199e41074c","component":"1dbc513e0e11z16","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"m191d0168cd1e718":{"_id":"m191d0168cd1e718","component":"1dbc513e0e11z19","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"q13ca018ddf1b2cb":{"_id":"q13ca018ddf1b2cb","component":"1dbc513e0e11z18","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"i17f271591b13ab8":{"_id":"i17f271591b13ab8","component":"1dbc513e0e11z17","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"z151551d71511af6":{"_id":"z151551d71511af6","component":"1dbc51200e11616","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-behavior.html', '_blank', true); \n}"},"r1c1e3143bb14fea":{"_id":"r1c1e3143bb14fea","component":"1dbc51200e11612","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g10e66157581049b":{"_id":"g10e66157581049b","component":"1dbc51200e11611","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save(); \n}"},"r1e032137771c493":{"_id":"r1e032137771c493","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"w1d94e18b9f10fe3":{"_id":"w1d94e18b9f10fe3","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'behavior',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/javascript',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'behavior',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"o1b89518d6212c82":{"_id":"o1b89518d6212c82","component":"1f1781882618110","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n try {\n this.require('store').data(JSON.parse(editor.getValue()));\n } catch (e) {\n }\n\n editor.setEditor('javascript',this.require('store').data().action, 2);\n}","useCoreAPI":false,"core":false},"a16d1816a121a0ca":{"_id":"a16d1816a121a0ca","component":"1f1781882618111","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n if (editor.getValue().indexOf('{') !== 0) {\n this.require('store').data().action = editor.getValue();\n }\n\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"r1841b145401b120":{"_id":"r1841b145401b120","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n behavior = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // set system\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n system = this.require('storage').get(systemId);\n \n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n\n // set store\n behavior = this.require('storage').get(systemId).behaviors[id];\n\n this.require('store').uuid(id);\n this.require('store').data(behavior);\n\n if (behavior.state === 'start' && systemId === behavior.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n } else {\n document.title = 'behavior ' + behavior.component + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n }\n\n this.require('editor').initValue(behavior.action, 2);\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"t103d416bd313444":{"_id":"t103d416bd313444","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n if (this.require('state').menu() === 'action') {\n store.action = val;\n } else {\n store = JSON.parse(val);\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorDeleteBehavior(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n if (store.state === 'start' && this.require('factory').system().id() === store.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + ' · ' + document.title.split('·')[1].trim();\n } else {\n document.title = 'behavior ' + this.require('store').data().component + '.' + this.require('store').data().state + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateBehavior(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Behavior saved.');\n}","useCoreAPI":false,"core":false},"l16eb31f3a515bb9":{"_id":"l16eb31f3a515bb9","component":"c1444b19a0c1ec4d","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"k1fa3c1a56a14081":{"_id":"k1fa3c1a56a14081","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"i1227d101301030a":{"_id":"i1227d101301030a","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"d17bbd1a0311a1d7":{"_id":"d17bbd1a0311a1d7","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"j1ee401128b14b0a":{"_id":"j1ee401128b14b0a","component":"r11f4117b5111373","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');;\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a154a417ccd16a26":{"_id":"a154a417ccd16a26","component":"u11695143131df2f","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x18e941f8721d9b3":{"_id":"x18e941f8721d9b3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bi":{"_id":"1f8571164c179bi","html":"menu-action-version.html","position":10,"type":"behavior"}},"MenuHeader":{"1fb101b99813a17":{"_id":"1fb101b99813a17","html":"menu-header-behavior.html","type":"behavior"}},"MenuItem":{"1f1781882618110":{"_id":"1f1781882618110","name":"action","html":"menu-item-action.html","position":10,"type":"behavior","platform":"all"},"1f1781882618111":{"_id":"1f1781882618111","name":"behavior","html":"menu-item-behavior.html","position":20,"type":"behavior","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc513e0e11z15":{"_id":"1dbc513e0e11z15","html":"toolbar-item-copy.html","position":50,"type":"behavior","platform":"electron"},"1dbc513e0e11z16":{"_id":"1dbc513e0e11z16","html":"toolbar-item-paste.html","position":60,"type":"behavior","platform":"electron"},"1dbc51200e11611":{"_id":"1dbc51200e11611","html":"toolbar-item-save.html","position":10,"type":"behavior","platform":"all"},"1dbc51200e11612":{"_id":"1dbc51200e11612","html":"toolbar-item-copyright.html","position":90,"type":"behavior","platform":"all"},"1dbc51200e11616":{"_id":"1dbc51200e11616","html":"toolbar-item-help.html","position":80,"type":"behavior","platform":"all"},"1dbc513e0e11z17":{"_id":"1dbc513e0e11z17","html":"toolbar-item-undo.html","position":20,"type":"behavior","platform":"all"},"1dbc513e0e11z18":{"_id":"1dbc513e0e11z18","html":"toolbar-item-redo.html","position":30,"type":"behavior","platform":"all"},"1dbc513e0e11z19":{"_id":"1dbc513e0e11z19","html":"toolbar-item-select-all.html","position":40,"type":"behavior","platform":"all"},"r11f4117b5111373":{"_id":"r11f4117b5111373","html":"toolbar-item-command.html","platform":"web","position":75,"type":"behavior"},"u11695143131df2f":{"_id":"u11695143131df2f","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"behavior"}}},"_id":"c1444b19a0c1ec4d"}); \ No newline at end of file +runtime.install({"name":"editor-behavior","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u165f215d0217974":{"_id":"u165f215d0217974","component":"1dbc513e0e11z15","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"f1846f199e41074c":{"_id":"f1846f199e41074c","component":"1dbc513e0e11z16","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"m191d0168cd1e718":{"_id":"m191d0168cd1e718","component":"1dbc513e0e11z19","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"q13ca018ddf1b2cb":{"_id":"q13ca018ddf1b2cb","component":"1dbc513e0e11z18","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"i17f271591b13ab8":{"_id":"i17f271591b13ab8","component":"1dbc513e0e11z17","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"z151551d71511af6":{"_id":"z151551d71511af6","component":"1dbc51200e11616","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-behavior.html', '_blank', true); \n}"},"r1c1e3143bb14fea":{"_id":"r1c1e3143bb14fea","component":"1dbc51200e11612","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g10e66157581049b":{"_id":"g10e66157581049b","component":"1dbc51200e11611","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save(); \n}"},"r1e032137771c493":{"_id":"r1e032137771c493","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"w1d94e18b9f10fe3":{"_id":"w1d94e18b9f10fe3","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'behavior',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/javascript',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'behavior',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"o1b89518d6212c82":{"_id":"o1b89518d6212c82","component":"1f1781882618110","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n try {\n this.require('store').data(JSON.parse(editor.getValue()));\n } catch (e) {\n }\n\n editor.setEditor('javascript',this.require('store').data().action, 2);\n}","useCoreAPI":false,"core":false},"a16d1816a121a0ca":{"_id":"a16d1816a121a0ca","component":"1f1781882618111","state":"click","action":"function click() { \n var editor = this.require('editor');\n\n if (editor.getValue().indexOf('{') !== 0) {\n this.require('store').data().action = editor.getValue();\n }\n\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"r1841b145401b120":{"_id":"r1841b145401b120","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n behavior = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // set system\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n system = this.require('storage').get(systemId);\n \n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n\n // set store\n behavior = this.require('storage').get(systemId).behaviors[id];\n\n this.require('store').uuid(id);\n this.require('store').data(behavior);\n\n if (behavior.state === 'start' && systemId === behavior.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n } else {\n document.title = 'behavior ' + behavior.component + '.' + behavior.state + ' · system ' + this.require('storage').get(systemId).name;\n }\n\n this.require('editor').initValue(behavior.action, 2);\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"t103d416bd313444":{"_id":"t103d416bd313444","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n if (this.require('state').menu() === 'action') {\n store.action = val;\n } else {\n store = JSON.parse(val);\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorDeleteBehavior(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n if (store.state === 'start' && this.require('factory').system().id() === store.component) {\n document.title = 'behavior ' + this.require('factory').system().name() + ' · ' + document.title.split('·')[1].trim();\n } else {\n document.title = 'behavior ' + this.require('store').data().component + '.' + this.require('store').data().state + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateBehavior(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Behavior saved.');\n}","useCoreAPI":false,"core":false},"l16eb31f3a515bb9":{"_id":"l16eb31f3a515bb9","component":"c1444b19a0c1ec4d","state":"start","action":"function start() { \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"k1fa3c1a56a14081":{"_id":"k1fa3c1a56a14081","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"i1227d101301030a":{"_id":"i1227d101301030a","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"d17bbd1a0311a1d7":{"_id":"d17bbd1a0311a1d7","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"j1ee401128b14b0a":{"_id":"j1ee401128b14b0a","component":"r11f4117b5111373","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');;\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a154a417ccd16a26":{"_id":"a154a417ccd16a26","component":"u11695143131df2f","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x18e941f8721d9b3":{"_id":"x18e941f8721d9b3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bi":{"_id":"1f8571164c179bi","html":"menu-action-version.html","position":10,"type":"behavior"}},"MenuHeader":{"1fb101b99813a17":{"_id":"1fb101b99813a17","html":"menu-header-behavior.html","type":"behavior"}},"MenuItem":{"1f1781882618110":{"_id":"1f1781882618110","name":"action","html":"menu-item-action.html","position":10,"type":"behavior","platform":"all"},"1f1781882618111":{"_id":"1f1781882618111","name":"behavior","html":"menu-item-behavior.html","position":20,"type":"behavior","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc513e0e11z15":{"_id":"1dbc513e0e11z15","html":"toolbar-item-copy.html","position":50,"type":"behavior","platform":"electron"},"1dbc513e0e11z16":{"_id":"1dbc513e0e11z16","html":"toolbar-item-paste.html","position":60,"type":"behavior","platform":"electron"},"1dbc51200e11611":{"_id":"1dbc51200e11611","html":"toolbar-item-save.html","position":10,"type":"behavior","platform":"all"},"1dbc51200e11612":{"_id":"1dbc51200e11612","html":"toolbar-item-copyright.html","position":90,"type":"behavior","platform":"all"},"1dbc51200e11616":{"_id":"1dbc51200e11616","html":"toolbar-item-help.html","position":80,"type":"behavior","platform":"all"},"1dbc513e0e11z17":{"_id":"1dbc513e0e11z17","html":"toolbar-item-undo.html","position":20,"type":"behavior","platform":"all"},"1dbc513e0e11z18":{"_id":"1dbc513e0e11z18","html":"toolbar-item-redo.html","position":30,"type":"behavior","platform":"all"},"1dbc513e0e11z19":{"_id":"1dbc513e0e11z19","html":"toolbar-item-select-all.html","position":40,"type":"behavior","platform":"all"},"r11f4117b5111373":{"_id":"r11f4117b5111373","html":"toolbar-item-command.html","platform":"web","position":75,"type":"behavior"},"u11695143131df2f":{"_id":"u11695143131df2f","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"behavior"}}},"_id":"c1444b19a0c1ec4d"}); \ No newline at end of file diff --git a/designer/scripts/editor-component.js b/designer/scripts/editor-component.js index deda623..3bc77c7 100644 --- a/designer/scripts/editor-component.js +++ b/designer/scripts/editor-component.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-component","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"x1013f12b661a249":{"_id":"x1013f12b661a249","component":"wdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"v1639613d361aacf":{"_id":"v1639613d361aacf","component":"wdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"g1a0081da861f758":{"_id":"g1a0081da861f758","component":"wdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"q1812b16012148e4":{"_id":"q1812b16012148e4","component":"wdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"f1f85510ffb1f7de":{"_id":"f1f85510ffb1f7de","component":"wdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"a1ca6b1c67e16e93":{"_id":"a1ca6b1c67e16e93","component":"1dbc51200e11617","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-component.html', '_blank', true);\n}"},"u1b6fb175031cb76":{"_id":"u1b6fb175031cb76","component":"1dbc51200e11614","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"n1e17b11f5d1fd1d":{"_id":"n1e17b11f5d1fd1d","component":"1dbc51200e11613","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"s10e461a0831354a":{"_id":"s10e461a0831354a","component":"MenuItem","state":"click","action":"function click() { \n var designer = this.require('designer'),\n editor = this.require('editor'),\n state = this.require('state'),\n extra = null,\n oldContext = '',\n context = '',\n val = '';\n\n state.previousMenu(state.menu());\n state.menu(this.name());\n\n extra = this.require('store').extra();\n oldContext = state.previousMenu();\n context = state.menu();\n val = editor.getValue();\n\n if (oldContext) {\n if (oldContext !== 'runtimeComponent') {\n if (extra[oldContext] === 'json') {\n this.require('store').data()[oldContext] = JSON.parse(editor.getValue());\n } else {\n this.require('store').data()[oldContext] = editor.getValue();\n }\n } else {\n this.require('store').data(JSON.parse(editor.getValue()));\n }\n }\n\n component = this.require('store').data();\n\n if (context !== 'runtimeComponent') {\n if (extra[context] === 'json') {\n editor.setEditor(extra[context], JSON.stringify(component[context], null, '\\t'), 2);\n } else {\n editor.setEditor(extra[context], component[context], 1, true);\n }\n } else {\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n }\n}","useCoreAPI":false,"core":false},"f1236f1ee1e1d68f":{"_id":"f1236f1ee1e1d68f","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'component',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'component',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b1c1bb1ef0416898":{"_id":"b1c1bb1ef0416898","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n types = null,\n title = '',\n collection = '',\n self = this,\n designer = this.require('designer'),\n result = {},\n property = '',\n propName = '',\n editor = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n collection = decodeURIComponent(document.location.href.split('#')[2].split('?')[0]);\n systemId = document.location.href.split('#')[3].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n component = system.components[collection][id];\n model = this.require('factory').getGeneratedModel(collection);\n\n function _init(props) {\n var propName = '',\n position = 0,\n menuitem = null,\n arrId = [];\n \n if (Object.keys(props)) {\n // add menuitems\n for (propName in props) {\n self.require('db').collections().HTML.insert({\n \"_id\": \"menu-item-property-\" + propName + \".html\",\n \"source\": '' + propName + ''\n });\n arrId = self.require('db').collections().MenuItem.insert({\n \"name\": propName,\n \"html\": \"menu-item-property-\" + propName + \".html\",\n \"position\": position + 10,\n \"type\": \"component\"\n });\n }\n\n // items\n var toto = self.require('menubar').items().sort(function (itemA, itemB) {\n var compA = runtime.require(itemA),\n compB = runtime.require(itemB);\n\n if (compA.position() > compB.position()) {\n return 1;\n }\n if (compA.position() < compB.position()) {\n return -1;\n }\n return 0;\n });\n // render\n self.require('menubar').render();\n }\n }\n\n this.require('store').uuid(id);\n this.require('store').collection(collection);\n this.require('store').data(component);\n\n for (property in component) {\n if (model[property] && model[property].type) {\n switch (true) {\n case model[property].type === 'html':\n result[property] = 'html';\n break;\n case model[property].type === 'javascript':\n result[property] = 'javascript';\n break;\n case model[property].type === 'css':\n result[property] = 'css';\n break;\n case model[property].type === 'json':\n result[property] = 'json';\n break;\n case model[property].type === 'object':\n result[property] = 'json';\n break;\n case model[property].type === 'text':\n result[property] = 'text';\n break;\n //case Array.isArray(model[property].type):\n //result[property] = 'array';\n //break;\n default:\n // case of object / json type\n types = system.types;\n if (\n types &&\n typeof types[model[property].type] !== 'undefined' &&\n (types[model[property].type].type === 'object' || types[model[property].type].type === 'json')\n ) {\n result[property] = 'json';\n }\n break;\n }\n }\n }\n\n this.require('store').extra(result);\n _init(result);\n\n document.title = 'component ' + id + ' · system ' + system.name;\n\n editor = this.require('editor');\n if (Object.keys(result).length === 0) {\n editor.setEditor('json', JSON.stringify(component, null, '\\t'), 2);\n } else {\n propName = Object.keys(result)[0];\n if (result[propName] === 'json') {\n editor.setEditor(result[propName], JSON.stringify(component[propName], null, '\\t'), 2);\n } else {\n editor.setEditor(result[propName], component[propName], 1, true);\n }\n }\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"z1bac81ce5915b1d":{"_id":"z1bac81ce5915b1d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n store = this.require('store').data(),\n state = this.require('state'),\n extra = this.require('store').extra(),\n factory = this.require('factory'),\n id = '';\n\n if (state.menu() === 'runtimeComponent') {\n try {\n store = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your component: your component has an invalid structure.');\n return;\n }\n\n if (!store._id) {\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n if (id) {\n store._id = id;\n } else {\n store._id = factory.generateId();\n }\n }\n if (store._id && store._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n } else {\n if (extra[state.menu()] === 'json') {\n store[state.menu()] = JSON.parse(val);\n } else {\n store[state.menu()] = val;\n }\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateComponentId(this.require('store').uuid(), this.require('store').data()._id, this.require('store').collection());\n this.require('channel').$editorDeleteComponent(this.require('store').uuid(), this.require('store').collection());\n\n this.require('store').uuid(this.require('store').data()._id);\n\n // update title\n document.title = 'component ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateComponent(this.require('store').uuid(), this.require('store').collection(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Component saved.');\n}","useCoreAPI":false,"core":false},"n1e0b41437a1ee21":{"_id":"n1e0b41437a1ee21","component":"x1f67a1a3311b2f4","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"m169e6148951d670":{"_id":"m169e6148951d670","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n systemId = document.location.href.split('#')[3].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"p16e0e101141aec7":{"_id":"p16e0e101141aec7","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var storage = this.require('storage'),\n config = storage.get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n storage.set('system-designer-message', message);\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n // message for server debug\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k141a418b2f1e2c1":{"_id":"k141a418b2f1e2c1","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"b1a55213199167b3":{"_id":"b1a55213199167b3","component":"r185da17faa18ba1","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a12e151c735189b9":{"_id":"a12e151c735189b9","component":"z125f2124301bac8","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y10fc61d1d41464f":{"_id":"y10fc61d1d41464f","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bj":{"_id":"1f8571164c179bj","html":"menu-action-version.html","position":10,"type":"component"}},"MenuHeader":{"1fb101b99813a18":{"_id":"1fb101b99813a18","html":"menu-header-component.html","type":"component"}},"MenuItem":{"1f1781882618113":{"_id":"1f1781882618113","name":"runtimeComponent","html":"menu-item-component.html","position":200,"type":"component","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"wdbc51200e11z03":{"_id":"wdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"component","platform":"electron"},"wdbc51200e11z04":{"_id":"wdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"component","platform":"electron"},"1dbc51200e11613":{"_id":"1dbc51200e11613","html":"toolbar-item-save.html","position":10,"type":"component","platform":"all"},"1dbc51200e11614":{"_id":"1dbc51200e11614","html":"toolbar-item-copyright.html","position":90,"type":"component","platform":"all"},"1dbc51200e11617":{"_id":"1dbc51200e11617","html":"toolbar-item-help.html","position":80,"type":"component","platform":"all"},"wdbc51200e11z00":{"_id":"wdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"component","platform":"all"},"wdbc51200e11z01":{"_id":"wdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"component","platform":"all"},"wdbc51200e11z02":{"_id":"wdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"component","platform":"all"},"r185da17faa18ba1":{"_id":"r185da17faa18ba1","html":"toolbar-item-command.html","platform":"web","position":75,"type":"component"},"z125f2124301bac8":{"_id":"z125f2124301bac8","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"component"}}},"_id":"x1f67a1a3311b2f4"}); \ No newline at end of file +runtime.install({"name":"editor-component","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"x1013f12b661a249":{"_id":"x1013f12b661a249","component":"wdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"v1639613d361aacf":{"_id":"v1639613d361aacf","component":"wdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"g1a0081da861f758":{"_id":"g1a0081da861f758","component":"wdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"q1812b16012148e4":{"_id":"q1812b16012148e4","component":"wdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"f1f85510ffb1f7de":{"_id":"f1f85510ffb1f7de","component":"wdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"a1ca6b1c67e16e93":{"_id":"a1ca6b1c67e16e93","component":"1dbc51200e11617","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-component.html', '_blank', true);\n}"},"u1b6fb175031cb76":{"_id":"u1b6fb175031cb76","component":"1dbc51200e11614","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"n1e17b11f5d1fd1d":{"_id":"n1e17b11f5d1fd1d","component":"1dbc51200e11613","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"s10e461a0831354a":{"_id":"s10e461a0831354a","component":"MenuItem","state":"click","action":"function click() { \n var designer = this.require('designer'),\n editor = this.require('editor'),\n state = this.require('state'),\n extra = null,\n oldContext = '',\n context = '',\n val = '';\n\n state.previousMenu(state.menu());\n state.menu(this.name());\n\n extra = this.require('store').extra();\n oldContext = state.previousMenu();\n context = state.menu();\n val = editor.getValue();\n\n if (oldContext) {\n if (oldContext !== 'runtimeComponent') {\n if (extra[oldContext] === 'json') {\n this.require('store').data()[oldContext] = JSON.parse(editor.getValue());\n } else {\n this.require('store').data()[oldContext] = editor.getValue();\n }\n } else {\n this.require('store').data(JSON.parse(editor.getValue()));\n }\n }\n\n component = this.require('store').data();\n\n if (context !== 'runtimeComponent') {\n if (extra[context] === 'json') {\n editor.setEditor(extra[context], JSON.stringify(component[context], null, '\\t'), 2);\n } else {\n editor.setEditor(extra[context], component[context], 1, true);\n }\n } else {\n editor.setEditor('json', JSON.stringify(this.require('store').data(), null, '\\t'), 2);\n }\n}","useCoreAPI":false,"core":false},"f1236f1ee1e1d68f":{"_id":"f1236f1ee1e1d68f","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'component',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'component',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b1c1bb1ef0416898":{"_id":"b1c1bb1ef0416898","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n types = null,\n title = '',\n collection = '',\n self = this,\n designer = this.require('designer'),\n result = {},\n property = '',\n propName = '',\n editor = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n collection = decodeURIComponent(document.location.href.split('#')[2].split('?')[0]);\n systemId = document.location.href.split('#')[3].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n component = system.components[collection][id];\n model = this.require('factory').getGeneratedModel(collection);\n\n function _init(props) {\n var propName = '',\n position = 0,\n menuitem = null,\n arrId = [];\n \n if (Object.keys(props)) {\n // add menuitems\n for (propName in props) {\n self.require('db').collections().HTML.insert({\n \"_id\": \"menu-item-property-\" + propName + \".html\",\n \"source\": '' + propName + ''\n });\n arrId = self.require('db').collections().MenuItem.insert({\n \"name\": propName,\n \"html\": \"menu-item-property-\" + propName + \".html\",\n \"position\": position + 10,\n \"type\": \"component\"\n });\n }\n\n // items\n var toto = self.require('menubar').items().sort(function (itemA, itemB) {\n var compA = runtime.require(itemA),\n compB = runtime.require(itemB);\n\n if (compA.position() > compB.position()) {\n return 1;\n }\n if (compA.position() < compB.position()) {\n return -1;\n }\n return 0;\n });\n // render\n self.require('menubar').render();\n }\n }\n\n this.require('store').uuid(id);\n this.require('store').collection(collection);\n this.require('store').data(component);\n\n for (property in component) {\n if (model[property] && model[property].type) {\n switch (true) {\n case model[property].type === 'html':\n result[property] = 'html';\n break;\n case model[property].type === 'javascript':\n result[property] = 'javascript';\n break;\n case model[property].type === 'css':\n result[property] = 'css';\n break;\n case model[property].type === 'json':\n result[property] = 'json';\n break;\n case model[property].type === 'object':\n result[property] = 'json';\n break;\n case model[property].type === 'text':\n result[property] = 'text';\n break;\n //case Array.isArray(model[property].type):\n //result[property] = 'array';\n //break;\n default:\n // case of object / json type\n types = system.types;\n if (\n types &&\n typeof types[model[property].type] !== 'undefined' &&\n (types[model[property].type].type === 'object' || types[model[property].type].type === 'json')\n ) {\n result[property] = 'json';\n }\n break;\n }\n }\n }\n\n this.require('store').extra(result);\n _init(result);\n\n document.title = 'component ' + id + ' · system ' + system.name;\n\n editor = this.require('editor');\n if (Object.keys(result).length === 0) {\n editor.setEditor('json', JSON.stringify(component, null, '\\t'), 2);\n } else {\n propName = Object.keys(result)[0];\n if (result[propName] === 'json') {\n editor.setEditor(result[propName], JSON.stringify(component[propName], null, '\\t'), 2);\n } else {\n editor.setEditor(result[propName], component[propName], 1, true);\n }\n }\n \n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"z1bac81ce5915b1d":{"_id":"z1bac81ce5915b1d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n store = this.require('store').data(),\n state = this.require('state'),\n extra = this.require('store').extra(),\n factory = this.require('factory'),\n id = '';\n\n if (state.menu() === 'runtimeComponent') {\n try {\n store = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your component: your component has an invalid structure.');\n return;\n }\n\n if (!store._id) {\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n if (id) {\n store._id = id;\n } else {\n store._id = factory.generateId();\n }\n }\n if (store._id && store._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n } else {\n if (extra[state.menu()] === 'json') {\n store[state.menu()] = JSON.parse(val);\n } else {\n store[state.menu()] = val;\n }\n }\n this.require('store').data(store);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateComponentId(this.require('store').uuid(), this.require('store').data()._id, this.require('store').collection());\n this.require('channel').$editorDeleteComponent(this.require('store').uuid(), this.require('store').collection());\n\n this.require('store').uuid(this.require('store').data()._id);\n\n // update title\n document.title = 'component ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateComponent(this.require('store').uuid(), this.require('store').collection(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('Component saved.');\n}","useCoreAPI":false,"core":false},"n1e0b41437a1ee21":{"_id":"n1e0b41437a1ee21","component":"x1f67a1a3311b2f4","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"m169e6148951d670":{"_id":"m169e6148951d670","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n systemId = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n systemId = document.location.href.split('#')[3].split('?')[0];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + systemId + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"p16e0e101141aec7":{"_id":"p16e0e101141aec7","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var storage = this.require('storage'),\n config = storage.get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n storage.set('system-designer-message', message);\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n // message for server debug\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k141a418b2f1e2c1":{"_id":"k141a418b2f1e2c1","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"b1a55213199167b3":{"_id":"b1a55213199167b3","component":"r185da17faa18ba1","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"a12e151c735189b9":{"_id":"a12e151c735189b9","component":"z125f2124301bac8","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y10fc61d1d41464f":{"_id":"y10fc61d1d41464f","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bj":{"_id":"1f8571164c179bj","html":"menu-action-version.html","position":10,"type":"component"}},"MenuHeader":{"1fb101b99813a18":{"_id":"1fb101b99813a18","html":"menu-header-component.html","type":"component"}},"MenuItem":{"1f1781882618113":{"_id":"1f1781882618113","name":"runtimeComponent","html":"menu-item-component.html","position":200,"type":"component","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"wdbc51200e11z03":{"_id":"wdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"component","platform":"electron"},"wdbc51200e11z04":{"_id":"wdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"component","platform":"electron"},"1dbc51200e11613":{"_id":"1dbc51200e11613","html":"toolbar-item-save.html","position":10,"type":"component","platform":"all"},"1dbc51200e11614":{"_id":"1dbc51200e11614","html":"toolbar-item-copyright.html","position":90,"type":"component","platform":"all"},"1dbc51200e11617":{"_id":"1dbc51200e11617","html":"toolbar-item-help.html","position":80,"type":"component","platform":"all"},"wdbc51200e11z00":{"_id":"wdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"component","platform":"all"},"wdbc51200e11z01":{"_id":"wdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"component","platform":"all"},"wdbc51200e11z02":{"_id":"wdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"component","platform":"all"},"r185da17faa18ba1":{"_id":"r185da17faa18ba1","html":"toolbar-item-command.html","platform":"web","position":75,"type":"component"},"z125f2124301bac8":{"_id":"z125f2124301bac8","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"component"}}},"_id":"x1f67a1a3311b2f4"}); \ No newline at end of file diff --git a/designer/scripts/editor-model.js b/designer/scripts/editor-model.js index b9b1856..a2ea05e 100644 --- a/designer/scripts/editor-model.js +++ b/designer/scripts/editor-model.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-model","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"t15f921e6a316234":{"_id":"t15f921e6a316234","component":"udbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"d10e191ee9813950":{"_id":"d10e191ee9813950","component":"udbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"i1a1951779613207":{"_id":"i1a1951779613207","component":"udbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"d1d8ee1ac3812186":{"_id":"d1d8ee1ac3812186","component":"udbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"i15954170f111203":{"_id":"i15954170f111203","component":"udbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"y1dbc0114c11c791":{"_id":"y1dbc0114c11c791","component":"1dbc51200e116e9","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save(); \n}"},"j1ac7610be61012b":{"_id":"j1ac7610be61012b","component":"1dbc51200e11615","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/edit-a-model.html', '_blank', true); \n}"},"g161d21f3a912625":{"_id":"g161d21f3a912625","component":"1dbc51200e11610","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"d1802118f46183c0":{"_id":"d1802118f46183c0","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'model',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'model',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"x1cd3e156f81600f":{"_id":"x1cd3e156f81600f","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n modelName = '',\n modelGen = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1].split('?')[0]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n model = system.models[id];\n\n this.require('store').uuid(id);\n this.require('store').data(model);\n\n modelName = system.models[id]._name;\n modelGen = this.require('factory').getGeneratedModel(modelName);\n this.require('store').extra(modelGen);\n\n document.title = 'model ' + model._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(model, null, '\\t'), 2);\n\n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"s1bc6b11e9a13afd":{"_id":"s1bc6b11e9a13afd","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n model = null,\n property = '',\n modelGen = null,\n hasError = false;\n\n try {\n model = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your model: your model has an invalid structure.');\n return;\n }\n \n \n // _inherit check\n if (typeof model._inherit !== 'undefined' && !Array.isArray(model._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf(model._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (model._inherit) {\n model._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof model._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (model._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n \n // clean name\n model._name = model._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // _id check\n if (typeof model._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (model._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n\n for (property in model) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = model[property];\n if (typeof propVal === 'object' && !Array.isArray(propVal) && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n if (property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n modelGen = this.require('store').extra();\n for (property in model) {\n if (property.indexOf('_') !== 0 && typeof modelGen[property] === 'undefined') {\n message.danger('Invalid property name \\'' + property + '\\’.
    \\'' + property + '\\’ must be defined in the schema.');\n return;\n }\n }\n\n if (this.require('store').data()._name === model._name) {\n this.require('store').data(model);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateModelId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateModel(this.require('store').uuid(), this.require('store').data());\n message.success('Model saved.');\n } else {\n message.danger('You can not modify the name of a model.');\n }\n}","useCoreAPI":false,"core":false},"z1b1ad1fdbb1a46a":{"_id":"z1b1ad1fdbb1a46a","component":"w1a78b16d7311831","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"t12f1412dc71b53b":{"_id":"t12f1412dc71b53b","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"q1db4d1ae7a19ae6":{"_id":"q1db4d1ae7a19ae6","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"m193c119f111fd88":{"_id":"m193c119f111fd88","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"s1a154168ce17fa9":{"_id":"s1a154168ce17fa9","component":"o1f40e168bd10174","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"c1e34c13e6b10bd9":{"_id":"c1e34c13e6b10bd9","component":"m1ff0113f491d841","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"f1c23c1dcb0122a3":{"_id":"f1c23c1dcb0122a3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bh":{"_id":"1f8571164c179bh","html":"menu-action-version.html","position":10,"type":"model"}},"MenuHeader":{"1fb101b99813a16":{"_id":"1fb101b99813a16","html":"menu-header-model.html","type":"model"}},"MenuItem":{"1f1781882618108":{"_id":"1f1781882618108","name":"model","html":"menu-item-model.html","position":10,"type":"model","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"udbc51200e11z03":{"_id":"udbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"model","platform":"electron"},"udbc51200e11z04":{"_id":"udbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"model","platform":"electron"},"1dbc51200e11610":{"_id":"1dbc51200e11610","html":"toolbar-item-copyright.html","position":90,"type":"model","platform":"all"},"1dbc51200e11615":{"_id":"1dbc51200e11615","html":"toolbar-item-help.html","position":80,"type":"model","platform":"all"},"1dbc51200e116e9":{"_id":"1dbc51200e116e9","html":"toolbar-item-save.html","position":10,"type":"model","platform":"all"},"udbc51200e11z00":{"_id":"udbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"model","platform":"all"},"udbc51200e11z01":{"_id":"udbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"model","platform":"all"},"udbc51200e11z02":{"_id":"udbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"model","platform":"all"},"o1f40e168bd10174":{"_id":"o1f40e168bd10174","html":"toolbar-item-command.html","platform":"web","position":75,"type":"model"},"m1ff0113f491d841":{"_id":"m1ff0113f491d841","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"model"}}},"_id":"w1a78b16d7311831"}); \ No newline at end of file +runtime.install({"name":"editor-model","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"],"refresh":"method"},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"t15f921e6a316234":{"_id":"t15f921e6a316234","component":"udbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"d10e191ee9813950":{"_id":"d10e191ee9813950","component":"udbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"i1a1951779613207":{"_id":"i1a1951779613207","component":"udbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"d1d8ee1ac3812186":{"_id":"d1d8ee1ac3812186","component":"udbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"i15954170f111203":{"_id":"i15954170f111203","component":"udbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"y1dbc0114c11c791":{"_id":"y1dbc0114c11c791","component":"1dbc51200e116e9","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save(); \n}"},"j1ac7610be61012b":{"_id":"j1ac7610be61012b","component":"1dbc51200e11615","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/edit-a-model.html', '_blank', true); \n}"},"g161d21f3a912625":{"_id":"g161d21f3a912625","component":"1dbc51200e11610","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"d1802118f46183c0":{"_id":"d1802118f46183c0","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'model',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'model',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"x1cd3e156f81600f":{"_id":"x1cd3e156f81600f","component":"Designer","state":"render","action":"function render() {\n var systemId = '',\n system = null,\n sys = null,\n id = '',\n modelName = '',\n modelGen = null;\n\n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1].split('?')[0]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n \n // set system\n system = this.require('storage').get(systemId);\n sys = this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // set editor\n system = this.require('storage').get(systemId);\n model = system.models[id];\n\n this.require('store').uuid(id);\n this.require('store').data(model);\n\n modelName = system.models[id]._name;\n modelGen = this.require('factory').getGeneratedModel(modelName);\n this.require('store').extra(modelGen);\n\n document.title = 'model ' + model._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(model, null, '\\t'), 2);\n\n this.require('router').update();\n \n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"s1bc6b11e9a13afd":{"_id":"s1bc6b11e9a13afd","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n model = null,\n property = '',\n modelGen = null,\n hasError = false;\n\n try {\n model = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your model: your model has an invalid structure.');\n return;\n }\n \n \n // _inherit check\n if (typeof model._inherit !== 'undefined' && !Array.isArray(model._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf(model._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (model._inherit && model._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (model._inherit) {\n model._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof model._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (model._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n \n // clean name\n model._name = model._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // _id check\n if (typeof model._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (model._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n\n for (property in model) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n propVal = model[property];\n if (typeof propVal === 'object' && !Array.isArray(propVal) && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n if (property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n modelGen = this.require('store').extra();\n for (property in model) {\n if (property.indexOf('_') !== 0 && typeof modelGen[property] === 'undefined') {\n message.danger('Invalid property name \\'' + property + '\\’.
    \\'' + property + '\\’ must be defined in the schema.');\n return;\n }\n }\n\n if (this.require('store').data()._name === model._name) {\n this.require('store').data(model);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateModelId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateModel(this.require('store').uuid(), this.require('store').data());\n message.success('Model saved.');\n } else {\n message.danger('You can not modify the name of a model.');\n }\n}","useCoreAPI":false,"core":false},"z1b1ad1fdbb1a46a":{"_id":"z1b1ad1fdbb1a46a","component":"w1a78b16d7311831","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"t12f1412dc71b53b":{"_id":"t12f1412dc71b53b","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"q1db4d1ae7a19ae6":{"_id":"q1db4d1ae7a19ae6","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"m193c119f111fd88":{"_id":"m193c119f111fd88","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"s1a154168ce17fa9":{"_id":"s1a154168ce17fa9","component":"o1f40e168bd10174","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"c1e34c13e6b10bd9":{"_id":"c1e34c13e6b10bd9","component":"m1ff0113f491d841","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"f1c23c1dcb0122a3":{"_id":"f1c23c1dcb0122a3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bh":{"_id":"1f8571164c179bh","html":"menu-action-version.html","position":10,"type":"model"}},"MenuHeader":{"1fb101b99813a16":{"_id":"1fb101b99813a16","html":"menu-header-model.html","type":"model"}},"MenuItem":{"1f1781882618108":{"_id":"1f1781882618108","name":"model","html":"menu-item-model.html","position":10,"type":"model","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"udbc51200e11z03":{"_id":"udbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"model","platform":"electron"},"udbc51200e11z04":{"_id":"udbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"model","platform":"electron"},"1dbc51200e11610":{"_id":"1dbc51200e11610","html":"toolbar-item-copyright.html","position":90,"type":"model","platform":"all"},"1dbc51200e11615":{"_id":"1dbc51200e11615","html":"toolbar-item-help.html","position":80,"type":"model","platform":"all"},"1dbc51200e116e9":{"_id":"1dbc51200e116e9","html":"toolbar-item-save.html","position":10,"type":"model","platform":"all"},"udbc51200e11z00":{"_id":"udbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"model","platform":"all"},"udbc51200e11z01":{"_id":"udbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"model","platform":"all"},"udbc51200e11z02":{"_id":"udbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"model","platform":"all"},"o1f40e168bd10174":{"_id":"o1f40e168bd10174","html":"toolbar-item-command.html","platform":"web","position":75,"type":"model"},"m1ff0113f491d841":{"_id":"m1ff0113f491d841","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"model"}}},"_id":"w1a78b16d7311831"}); \ No newline at end of file diff --git a/designer/scripts/editor-schema.js b/designer/scripts/editor-schema.js index df7e23e..b42f652 100644 --- a/designer/scripts/editor-schema.js +++ b/designer/scripts/editor-schema.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-schema","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"d10d6e1b5571c73b":{"_id":"d10d6e1b5571c73b","component":"tdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"m17c7d1483011aa2":{"_id":"m17c7d1483011aa2","component":"tdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"y19bc51629a15aca":{"_id":"y19bc51629a15aca","component":"tdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"p150db1b77d11ba1":{"_id":"p150db1b77d11ba1","component":"tdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"h1c4c115aa81281f":{"_id":"h1c4c115aa81281f","component":"tdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"f14706139781d16b":{"_id":"f14706139781d16b","component":"1dbc51200e116e8","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"w1e52a173f31d0da":{"_id":"w1e52a173f31d0da","component":"1dbc51200e116e7","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"e1bb25114121f519":{"_id":"e1bb25114121f519","component":"1dbc51200e11510","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-schema.html', '_blank', true); \n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'schema',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'schema',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null,\n schema = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editor\n system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n schema = system.schemas[id];\n\n this.require('store').uuid(id);\n this.require('store').data(schema);\n\n document.title = 'schema ' + schema._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(schema, null, '\\t'), 2);\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"u102ee100eb1fb61":{"_id":"u102ee100eb1fb61","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n schema = null,\n property = '',\n propVal = '',\n hasError = false;\n\n try {\n schema = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your schema: your schema has an invalid structure.');\n return;\n }\n \n // global properties check\n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') !== 0) {\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) === -1) {\n message.danger('Invalid value for the property \\'' + property + '\\’.
    Authorized values are: \\'property\\', \\'link\\', \\'collection\\', \\'event\\' and \\'method\\'.');\n return;\n }\n }\n }\n \n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n for (property in schema) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n if (property.match(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi)) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Invalid character found in the name of a property.');\n return;\n }\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) !== -1 && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n }\n \n // _inherit check\n if (typeof schema._inherit !== 'undefined' && !Array.isArray(schema._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf(schema._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (schema._inherit) {\n schema._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof schema._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (schema._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n\n // _id check\n if (typeof schema._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (schema._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n \n // clean name\n schema._name = schema._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // check if _name had changed\n if (this.require('store').data()._name !== schema._name) {\n this.require('channel').$editorUpdateSchemaName(schema._name, this.require('store').uuid());\n document.title = 'schema ' + schema._name + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('store').data(schema);\n\n // check if _id has changed\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateSchemaId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateSchema(this.require('store').uuid(), this.require('store').data());\n message.success('Schema saved.');\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"l1ffcf1761317c7b","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"l178f0159e514a91":{"_id":"l178f0159e514a91","component":"p13d881c2fe174bd","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1c98019d4c1d53c":{"_id":"y1c98019d4c1d53c","component":"u1c5aa1b25d1e8e5","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"schema"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"schema"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"schema","html":"menu-item-schema.html","position":10,"type":"schema","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"tdbc51200e11z03":{"_id":"tdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"schema","platform":"electron"},"tdbc51200e11z04":{"_id":"tdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"schema","platform":"electron"},"1dbc51200e11510":{"_id":"1dbc51200e11510","html":"toolbar-item-help.html","position":80,"type":"schema","platform":"all"},"1dbc51200e116e7":{"_id":"1dbc51200e116e7","html":"toolbar-item-save.html","position":10,"type":"schema","platform":"all"},"1dbc51200e116e8":{"_id":"1dbc51200e116e8","html":"toolbar-item-copyright.html","position":90,"type":"schema","platform":"all"},"tdbc51200e11z00":{"_id":"tdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"schema","platform":"all"},"tdbc51200e11z01":{"_id":"tdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"schema","platform":"all"},"tdbc51200e11z02":{"_id":"tdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"schema","platform":"all"},"p13d881c2fe174bd":{"_id":"p13d881c2fe174bd","html":"toolbar-item-command.html","platform":"web","position":75,"type":"schema"},"u1c5aa1b25d1e8e5":{"_id":"u1c5aa1b25d1e8e5","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"schema"}}},"_id":"l1ffcf1761317c7b"}); \ No newline at end of file +runtime.install({"name":"editor-schema","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"d10d6e1b5571c73b":{"_id":"d10d6e1b5571c73b","component":"tdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"m17c7d1483011aa2":{"_id":"m17c7d1483011aa2","component":"tdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"y19bc51629a15aca":{"_id":"y19bc51629a15aca","component":"tdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"p150db1b77d11ba1":{"_id":"p150db1b77d11ba1","component":"tdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"h1c4c115aa81281f":{"_id":"h1c4c115aa81281f","component":"tdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"f14706139781d16b":{"_id":"f14706139781d16b","component":"1dbc51200e116e8","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"w1e52a173f31d0da":{"_id":"w1e52a173f31d0da","component":"1dbc51200e116e7","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"e1bb25114121f519":{"_id":"e1bb25114121f519","component":"1dbc51200e11510","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-schema.html', '_blank', true); \n}"},"b18fab15f501e117":{"_id":"b18fab15f501e117","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'schema',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'schema',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"b105d21fac11b017":{"_id":"b105d21fac11b017","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = null,\n schema = null;\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editor\n system = this.require('storage').get(systemId);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n schema = system.schemas[id];\n\n this.require('store').uuid(id);\n this.require('store').data(schema);\n\n document.title = 'schema ' + schema._name + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(schema, null, '\\t'), 2);\n\n // router\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"u102ee100eb1fb61":{"_id":"u102ee100eb1fb61","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n message = this.require('message'),\n schema = null,\n property = '',\n propVal = '',\n hasError = false;\n\n try {\n schema = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your schema: your schema has an invalid structure.');\n return;\n }\n \n // global properties check\n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') !== 0) {\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) === -1) {\n message.danger('Invalid value for the property \\'' + property + '\\’.
    Authorized values are: \\'property\\', \\'link\\', \\'collection\\', \\'event\\' and \\'method\\'.');\n return;\n }\n }\n }\n \n for (property in schema) {\n if (schema.hasOwnProperty(property) && property.indexOf('_') === 0) {\n if (['_id', '_name', '_inherit', '_class', '_core', '_description'].indexOf(property) === -1) {\n message.danger('Invalid value \\'' + property + '\\’.
    Authorized values are: \\'_id\\', \\'_name\\', \\'_inherit\\', \\'_class\\', \\'_core\\' and \\'_description\\'.');\n return;\n }\n }\n }\n\n for (property in schema) {\n if (property.indexOf(' ') !== -1) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Space is not authorized in the name of a property.');\n return;\n }\n if (property.match(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi)) {\n message.danger('Invalid property name \\'' + property + '\\’.
    Invalid character found in the name of a property.');\n return;\n }\n propVal = schema[property];\n if (['property', 'link', 'collection', 'event', 'method'].indexOf(propVal) !== -1 && property.indexOf('_') === 0) {\n message.danger('Invalid property name \\'' + property + '\\’.
    A property name can not start with \\'_\\'.');\n return;\n }\n }\n \n // _inherit check\n if (typeof schema._inherit !== 'undefined' && !Array.isArray(schema._inherit)) {\n message.danger('Invalid inheritance value: it must be an array.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf(schema._name) !== -1) {\n message.danger('Invalid inheritance value: you can not inherit from yourself.');\n return;\n }\n \n if (schema._inherit && schema._inherit.indexOf('') !== -1) {\n message.danger('Invalid inheritance value: it can not be empty.');\n return;\n }\n\n if (schema._inherit) {\n schema._inherit.forEach(function (parent) {\n if (parent.constructor.name !== 'String') {\n hasError = true;\n }\n });\n if (hasError) {\n message.danger('Invalid inheritance value: it must be a string.');\n return;\n }\n }\n\n // _name check\n if (typeof schema._name === 'undefined') {\n message.danger('The property \\'_name\\' is missing.');\n return;\n }\n \n if (schema._name.constructor.name !== 'String') {\n message.danger('The property \\'_name\\' must be a string.');\n return;\n }\n\n // _id check\n if (typeof schema._id === 'undefined') {\n message.danger('The property \\'_id\\' is missing.');\n return;\n }\n \n if (schema._id.constructor.name !== 'String') {\n message.danger('The property \\'_id\\' must be a string.');\n return;\n }\n \n // clean name\n schema._name = schema._name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n // check if _name had changed\n if (this.require('store').data()._name !== schema._name) {\n this.require('channel').$editorUpdateSchemaName(schema._name, this.require('store').uuid());\n document.title = 'schema ' + schema._name + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('store').data(schema);\n\n // check if _id has changed\n if (this.require('store').uuid() !== this.require('store').data()._id) {\n this.require('channel').$editorUpdateSchemaId(this.require('store').uuid(), this.require('store').data()._id);\n this.require('store').uuid(this.require('store').data()._id);\n }\n\n this.require('channel').$editorUpdateSchema(this.require('store').uuid(), this.require('store').data());\n message.success('Schema saved.');\n}","useCoreAPI":false,"core":false},"k171ad182081ca3c":{"_id":"k171ad182081ca3c","component":"l1ffcf1761317c7b","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"q16ab5185c81f37d":{"_id":"q16ab5185c81f37d","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1e0be117b312cf0":{"_id":"t1e0be117b312cf0","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state'),\n system = {};\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"i12aee1bd7815e89":{"_id":"i12aee1bd7815e89","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"l178f0159e514a91":{"_id":"l178f0159e514a91","component":"p13d881c2fe174bd","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1c98019d4c1d53c":{"_id":"y1c98019d4c1d53c","component":"u1c5aa1b25d1e8e5","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"g1d47010c7e1904c":{"_id":"g1d47010c7e1904c","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bg":{"_id":"1f8571164c179bg","html":"menu-action-version.html","position":10,"type":"schema"}},"MenuHeader":{"1fb101b99813a15":{"_id":"1fb101b99813a15","html":"menu-header-schema.html","type":"schema"}},"MenuItem":{"1f1781882618106":{"_id":"1f1781882618106","name":"schema","html":"menu-item-schema.html","position":10,"type":"schema","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"tdbc51200e11z03":{"_id":"tdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"schema","platform":"electron"},"tdbc51200e11z04":{"_id":"tdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"schema","platform":"electron"},"1dbc51200e11510":{"_id":"1dbc51200e11510","html":"toolbar-item-help.html","position":80,"type":"schema","platform":"all"},"1dbc51200e116e7":{"_id":"1dbc51200e116e7","html":"toolbar-item-save.html","position":10,"type":"schema","platform":"all"},"1dbc51200e116e8":{"_id":"1dbc51200e116e8","html":"toolbar-item-copyright.html","position":90,"type":"schema","platform":"all"},"tdbc51200e11z00":{"_id":"tdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"schema","platform":"all"},"tdbc51200e11z01":{"_id":"tdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"schema","platform":"all"},"tdbc51200e11z02":{"_id":"tdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"schema","platform":"all"},"p13d881c2fe174bd":{"_id":"p13d881c2fe174bd","html":"toolbar-item-command.html","platform":"web","position":75,"type":"schema"},"u1c5aa1b25d1e8e5":{"_id":"u1c5aa1b25d1e8e5","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"schema"}}},"_id":"l1ffcf1761317c7b"}); \ No newline at end of file diff --git a/designer/scripts/editor-system.js b/designer/scripts/editor-system.js index 71160fe..ae81f2e 100644 --- a/designer/scripts/editor-system.js +++ b/designer/scripts/editor-system.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-system","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u1148712dc118eea":{"_id":"u1148712dc118eea","component":"sdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"l1c2d911d83104a2":{"_id":"l1c2d911d83104a2","component":"sdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"a194c816a861f58c":{"_id":"a194c816a861f58c","component":"sdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"u1ad2a18ae7197d7":{"_id":"u1ad2a18ae7197d7","component":"sdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"m12f44111501c769":{"_id":"m12f44111501c769","component":"sdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"g1fcf31e19f15b6f":{"_id":"g1fcf31e19f15b6f","component":"1dbc51200e11z10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-system.html', '_blank', true); \n}"},"j190d61dacc1fb05":{"_id":"j190d61dacc1fb05","component":"1dbc51200e116e4","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"c1076f15499194ba":{"_id":"c1076f15499194ba","component":"13a291c27f16311","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"a1b1d011fe31872d":{"_id":"a1b1d011fe31872d","component":"v1c4421834f1995a","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"z1b2ed1f26c196e0":{"_id":"z1b2ed1f26c196e0","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"p1e0b1155ea1f248":{"_id":"p1e0b1155ea1f248","component":"1f1781882618115","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'name';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().name, 1);\n}","useCoreAPI":false,"core":false},"r1edbf1004f16a37":{"_id":"r1edbf1004f16a37","component":"1f1781882618114","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'description';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().description, 1);\n}","useCoreAPI":false,"core":false},"o1626e18db0119a9":{"_id":"o1626e18db0119a9","component":"1f1781882618116","state":"click","action":"function click() { \n var editor = this.require('editor'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'version';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().version, 1);\n}","useCoreAPI":false,"core":false},"o1363f106aa19961":{"_id":"o1363f106aa19961","component":"1f1781882618102","state":"click","action":"function click() { \n var editor = this.require('editor'),\n data = this.require('store').data(),\n extra = this.require('store').extra();\n \n if (extra && extra.context && editor.getValue().indexOf('{') !== 0) {\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n \n editor.setEditor('json', JSON.stringify(data, null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"n1a54b1da681f33e":{"_id":"n1a54b1da681f33e","component":"Workspace","state":"render","action":"function render() {\n var Editor = null,\n editor = null,\n designer = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'system',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/x-textile',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'system',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"g1e35b1112512787":{"_id":"g1e35b1112512787","component":"Designer","state":"render","action":"function render() {\n var id = '',\n system = null,\n extra = {};\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n \n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n \n // set editor\n system = this.require('storage').get(id);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n this.require('store').uuid(id);\n this.require('store').data(system);\n\n document.title = 'system ' + system.name;\n\n extra.context = 'name';\n this.require('store').extra(extra);\n\n this.require('editor').initValue(this.require('store').data().name, 1);\n \n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"f199b4184ea1639d":{"_id":"f199b4184ea1639d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n switch (this.require('state').menu()) {\n case 'name':\n val = val.trim();\n val = val.replace(/\\s|\\t/gi, '-')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n this.require('editor').setValue(val);\n store.name = val;\n document.title = 'system ' + store.name;\n break;\n case 'description':\n store.description = val.trim();\n break;\n case 'version':\n store.version = val.trim();\n break;\n case 'bundle':\n store = JSON.parse(val);\n document.title = 'system ' + store.name;\n break;\n default:\n break;\n }\n\n this.require('store').data(store);\n\n this.require('channel').$editorUpdateSystem(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('System saved.');\n}","useCoreAPI":false,"core":false},"x1645919b431ab61":{"_id":"x1645919b431ab61","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1].split('?')[0];\n menubar[i].href = '#' + this.require('store').uuid() + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"g1c050192531348c":{"_id":"g1c050192531348c","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k1473f1cbe41b194":{"_id":"k1473f1cbe41b194","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"w1aa16102d712d94":{"_id":"w1aa16102d712d94","component":"x1cfa910cac1f8da","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"l11b92128ce147e8":{"_id":"l11b92128ce147e8","component":"k13bb31b8681ba70","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"p1e6c41a4bc1b4d3":{"_id":"p1e6c41a4bc1b4d3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179be":{"_id":"1f8571164c179be","html":"menu-action-version.html","position":10,"type":"system"}},"MenuHeader":{"1fb101b99813a13":{"_id":"1fb101b99813a13","html":"menu-header-system.html","type":"system"}},"MenuItem":{"1f1781882618102":{"_id":"1f1781882618102","name":"bundle","html":"menu-item-bundle.html","position":50,"type":"system","platform":"all"},"1f1781882618114":{"_id":"1f1781882618114","name":"description","html":"menu-item-description.html","position":30,"type":"system","platform":"all"},"1f1781882618115":{"_id":"1f1781882618115","name":"name","html":"menu-item-name.html","position":10,"type":"system","platform":"all"},"1f1781882618116":{"_id":"1f1781882618116","name":"version","html":"menu-item-version.html","position":20,"type":"system","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"sdbc51200e11z03":{"_id":"sdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"system","platform":"electron"},"sdbc51200e11z04":{"_id":"sdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"system","platform":"electron"},"13a291c27f16311":{"_id":"13a291c27f16311","html":"toolbar-item-copyright.html","position":90,"type":"system","platform":"all"},"1dbc51200e116e4":{"_id":"1dbc51200e116e4","html":"toolbar-item-save.html","position":10,"type":"system","platform":"all"},"1dbc51200e11z10":{"_id":"1dbc51200e11z10","html":"toolbar-item-help.html","position":80,"type":"system","platform":"all"},"sdbc51200e11z00":{"_id":"sdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"system","platform":"all"},"sdbc51200e11z01":{"_id":"sdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"system","platform":"all"},"sdbc51200e11z02":{"_id":"sdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"system","platform":"all"},"x1cfa910cac1f8da":{"_id":"x1cfa910cac1f8da","html":"toolbar-item-command.html","platform":"web","position":75,"type":"system"},"k13bb31b8681ba70":{"_id":"k13bb31b8681ba70","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"system"}}},"_id":"v1c4421834f1995a"}); \ No newline at end of file +runtime.install({"name":"editor-system","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"addShortcuts":{}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"u1148712dc118eea":{"_id":"u1148712dc118eea","component":"sdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy(); \n this.require('message').success('The text has been copied to the clipboard.');\n}"},"l1c2d911d83104a2":{"_id":"l1c2d911d83104a2","component":"sdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"a194c816a861f58c":{"_id":"a194c816a861f58c","component":"sdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"u1ad2a18ae7197d7":{"_id":"u1ad2a18ae7197d7","component":"sdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"m12f44111501c769":{"_id":"m12f44111501c769","component":"sdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"g1fcf31e19f15b6f":{"_id":"g1fcf31e19f15b6f","component":"1dbc51200e11z10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-system.html', '_blank', true); \n}"},"j190d61dacc1fb05":{"_id":"j190d61dacc1fb05","component":"1dbc51200e116e4","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"c1076f15499194ba":{"_id":"c1076f15499194ba","component":"13a291c27f16311","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"a1b1d011fe31872d":{"_id":"a1b1d011fe31872d","component":"v1c4421834f1995a","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"z1b2ed1f26c196e0":{"_id":"z1b2ed1f26c196e0","component":"MenuItem","state":"click","action":"function click() { \n this.require('state').menu(this.name());\n}","useCoreAPI":false,"core":false},"p1e0b1155ea1f248":{"_id":"p1e0b1155ea1f248","component":"1f1781882618115","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'name';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().name, 1);\n}","useCoreAPI":false,"core":false},"r1edbf1004f16a37":{"_id":"r1edbf1004f16a37","component":"1f1781882618114","state":"click","action":"function click() { \n var editor = this.require('editor'),\n designer = this.require('designer'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'description';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().description, 1);\n}","useCoreAPI":false,"core":false},"o1626e18db0119a9":{"_id":"o1626e18db0119a9","component":"1f1781882618116","state":"click","action":"function click() { \n var editor = this.require('editor'),\n extra = {},\n data = {};\n\n if (editor.getValue().indexOf('{') === 0) {\n this.require('store').data(JSON.parse(editor.getValue()));\n } else {\n extra = this.require('store').extra();\n if (extra && extra.context) {\n data = this.require('store').data();\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n }\n\n extra = {};\n extra.context = 'version';\n this.require('store').extra(extra);\n\n editor.setEditor('text', this.require('store').data().version, 1);\n}","useCoreAPI":false,"core":false},"o1363f106aa19961":{"_id":"o1363f106aa19961","component":"1f1781882618102","state":"click","action":"function click() { \n var editor = this.require('editor'),\n data = this.require('store').data(),\n extra = this.require('store').extra();\n \n if (extra && extra.context && editor.getValue().indexOf('{') !== 0) {\n data[extra.context] = editor.getValue();\n this.require('store').data(data);\n }\n \n editor.setEditor('json', JSON.stringify(data, null, '\\t'), 2);\n}","useCoreAPI":false,"core":false},"n1a54b1da681f33e":{"_id":"n1a54b1da681f33e","component":"Workspace","state":"render","action":"function render() {\n var Editor = null,\n editor = null,\n designer = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'system',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'text/x-textile',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'system',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"g1e35b1112512787":{"_id":"g1e35b1112512787","component":"Designer","state":"render","action":"function render() {\n var id = '',\n system = null,\n extra = {};\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n \n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = document.location.href.split('#')[1].split('?')[0];\n \n // set editor\n system = this.require('storage').get(id);\n \n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n\n this.require('store').uuid(id);\n this.require('store').data(system);\n\n document.title = 'system ' + system.name;\n\n extra.context = 'name';\n this.require('store').extra(extra);\n\n this.require('editor').initValue(this.require('store').data().name, 1);\n \n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"f199b4184ea1639d":{"_id":"f199b4184ea1639d","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n designer = this.require('designer'),\n store = this.require('store').data();\n\n switch (this.require('state').menu()) {\n case 'name':\n val = val.trim();\n val = val.replace(/\\s|\\t/gi, '-')\n .replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n this.require('editor').setValue(val);\n store.name = val;\n document.title = 'system ' + store.name;\n break;\n case 'description':\n store.description = val.trim();\n break;\n case 'version':\n store.version = val.trim();\n break;\n case 'bundle':\n store = JSON.parse(val);\n document.title = 'system ' + store.name;\n break;\n default:\n break;\n }\n\n this.require('store').data(store);\n\n this.require('channel').$editorUpdateSystem(this.require('store').uuid(), this.require('store').data());\n this.require('message').clean();\n this.require('message').success('System saved.');\n}","useCoreAPI":false,"core":false},"x1645919b431ab61":{"_id":"x1645919b431ab61","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1].split('?')[0];\n menubar[i].href = '#' + this.require('store').uuid() + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"g1c050192531348c":{"_id":"g1c050192531348c","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n\n if (designer.isCordova()) {\n state.messages().push(message);\n }\n\n this.require('storage').set('system-designer-message', message);\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"k1473f1cbe41b194":{"_id":"k1473f1cbe41b194","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":false,"core":false},"w1aa16102d712d94":{"_id":"w1aa16102d712d94","component":"x1cfa910cac1f8da","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"l11b92128ce147e8":{"_id":"l11b92128ce147e8","component":"k13bb31b8681ba70","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"p1e6c41a4bc1b4d3":{"_id":"p1e6c41a4bc1b4d3","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179be":{"_id":"1f8571164c179be","html":"menu-action-version.html","position":10,"type":"system"}},"MenuHeader":{"1fb101b99813a13":{"_id":"1fb101b99813a13","html":"menu-header-system.html","type":"system"}},"MenuItem":{"1f1781882618102":{"_id":"1f1781882618102","name":"bundle","html":"menu-item-bundle.html","position":50,"type":"system","platform":"all"},"1f1781882618114":{"_id":"1f1781882618114","name":"description","html":"menu-item-description.html","position":30,"type":"system","platform":"all"},"1f1781882618115":{"_id":"1f1781882618115","name":"name","html":"menu-item-name.html","position":10,"type":"system","platform":"all"},"1f1781882618116":{"_id":"1f1781882618116","name":"version","html":"menu-item-version.html","position":20,"type":"system","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"sdbc51200e11z03":{"_id":"sdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"system","platform":"electron"},"sdbc51200e11z04":{"_id":"sdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"system","platform":"electron"},"13a291c27f16311":{"_id":"13a291c27f16311","html":"toolbar-item-copyright.html","position":90,"type":"system","platform":"all"},"1dbc51200e116e4":{"_id":"1dbc51200e116e4","html":"toolbar-item-save.html","position":10,"type":"system","platform":"all"},"1dbc51200e11z10":{"_id":"1dbc51200e11z10","html":"toolbar-item-help.html","position":80,"type":"system","platform":"all"},"sdbc51200e11z00":{"_id":"sdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"system","platform":"all"},"sdbc51200e11z01":{"_id":"sdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"system","platform":"all"},"sdbc51200e11z02":{"_id":"sdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"system","platform":"all"},"x1cfa910cac1f8da":{"_id":"x1cfa910cac1f8da","html":"toolbar-item-command.html","platform":"web","position":75,"type":"system"},"k13bb31b8681ba70":{"_id":"k13bb31b8681ba70","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"system"}}},"_id":"v1c4421834f1995a"}); \ No newline at end of file diff --git a/designer/scripts/editor-type.js b/designer/scripts/editor-type.js index a14c5bd..fd34b76 100644 --- a/designer/scripts/editor-type.js +++ b/designer/scripts/editor-type.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"editor-type","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"any","params":[{"name":"param","type":"any","mandatory":false,"default":null}]},"addShorcuts":{},"addShortcuts":{"params":[{"name":"param","type":"any","mandatory":false,"default":null}],"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"m134c713c841c559":{"_id":"m134c713c841c559","component":"vdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"w1f5751bd9e15f00":{"_id":"w1f5751bd9e15f00","component":"vdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"s163371531d1ec0a":{"_id":"s163371531d1ec0a","component":"vdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"e1eabd18b6717d03":{"_id":"e1eabd18b6717d03","component":"vdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"h1bee51638018e23":{"_id":"h1bee51638018e23","component":"vdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"t197d11eeee1e568":{"_id":"t197d11eeee1e568","component":"1dbc51200e116e6","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g1dfae1d94d10ce1":{"_id":"g1dfae1d94d10ce1","component":"1dbc51200e116e5","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"y1fd9e171d717b39":{"_id":"y1fd9e171d717b39","component":"1dbc51200e116e10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-type.html', '_blank', true); \n}"},"w108111c7dc1ca6b":{"_id":"w108111c7dc1ca6b","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'type',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'type',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"t17faa1c1e816821":{"_id":"t17faa1c1e816821","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = '',\n type = '';\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editors\n system = this.require('storage').get(systemId);\n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n type = system.types[id];\n this.require('store').uuid(id);\n this.require('store').data(type);\n\n document.title = 'type ' + id + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(type, null, '\\t'), 2);\n\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"y14257199751564c":{"_id":"y14257199751564c","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n type = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n try {\n type = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your type: your type has an invalid structure.');\n return;\n }\n\n if (!type.name) {\n message.danger('The property \\'name\\' is missing.');\n return;\n }\n \n // clean name\n type.name = type.name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n if (!type.type) {\n message.danger('The property \\'type\\' is missing.');\n return;\n }\n\n if (type._id && type._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n\n this.require('store').data(type);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data().name) {\n this.require('channel').$editorDeleteType(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data().name);\n\n // update title\n document.title = 'type ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateType(this.require('store').uuid(), this.require('store').data());\n message.success('Type saved.');\n}","useCoreAPI":false,"core":false},"r1df8d1a54e1c14f":{"_id":"r1df8d1a54e1c14f","component":"w1667a15e2a1e2ef","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"b182a81e1c7173c3":{"_id":"b182a81e1c7173c3","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1249a1a35319140":{"_id":"t1249a1a35319140","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n \n this.require('storage').set('system-designer-message', message);\n \n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"c1b2a41e5e61459c":{"_id":"c1b2a41e5e61459c","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n}, true);\n}","useCoreAPI":false,"core":false},"a1eabd1ce561031c":{"_id":"a1eabd1ce561031c","component":"y174dd1c4fb187ed","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y133f11e82c1aad7":{"_id":"y133f11e82c1aad7","component":"k1423a15ea412f5d","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x13d2a197b411642":{"_id":"x13d2a197b411642","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bf":{"_id":"1f8571164c179bf","html":"menu-action-version.html","position":10,"type":"type"}},"MenuHeader":{"1fb101b99813a14":{"_id":"1fb101b99813a14","html":"menu-header-type.html","type":"type"}},"MenuItem":{"1f1781882618104":{"_id":"1f1781882618104","name":"type","html":"menu-item-type.html","position":10,"type":"type","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"vdbc51200e11z03":{"_id":"vdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"type","platform":"electron"},"vdbc51200e11z04":{"_id":"vdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"type","platform":"electron"},"1dbc51200e116e10":{"_id":"1dbc51200e116e10","html":"toolbar-item-help.html","position":80,"type":"type","platform":"all"},"1dbc51200e116e5":{"_id":"1dbc51200e116e5","html":"toolbar-item-save.html","position":10,"type":"type","platform":"all"},"1dbc51200e116e6":{"_id":"1dbc51200e116e6","html":"toolbar-item-copyright.html","position":90,"type":"type","platform":"all"},"vdbc51200e11z00":{"_id":"vdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"type","platform":"all"},"vdbc51200e11z01":{"_id":"vdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"type","platform":"all"},"vdbc51200e11z02":{"_id":"vdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"type","platform":"all"},"y174dd1c4fb187ed":{"_id":"y174dd1c4fb187ed","html":"toolbar-item-command.html","platform":"web","position":75,"type":"type"},"k1423a15ea412f5d":{"_id":"k1423a15ea412f5d","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"type"}}},"_id":"w1667a15e2a1e2ef"}); \ No newline at end of file +runtime.install({"name":"editor-type","master":true,"version":"1.0.0","description":"","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","addShortcuts":"method"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"]},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"any","params":[{"name":"param","type":"any","mandatory":false,"default":null}]},"addShorcuts":{},"addShortcuts":{"params":[{"name":"param","type":"any","mandatory":false,"default":null}],"result":"any"}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10"},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"m134c713c841c559":{"_id":"m134c713c841c559","component":"vdbc51200e11z03","state":"click","action":"function click() { \n $('#designer-toolbar-item-copy').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').copy();\n this.require('message').success('The text has been copied to the clipboard.');\n}"},"w1f5751bd9e15f00":{"_id":"w1f5751bd9e15f00","component":"vdbc51200e11z04","state":"click","action":"function click() { \n $('#designer-toolbar-item-paste').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').paste(); \n}"},"s163371531d1ec0a":{"_id":"s163371531d1ec0a","component":"vdbc51200e11z02","state":"click","action":"function click() { \n $('#designer-toolbar-item-select-all').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').selectAll(); \n}"},"e1eabd18b6717d03":{"_id":"e1eabd18b6717d03","component":"vdbc51200e11z01","state":"click","action":"function click() { \n $('#designer-toolbar-item-redo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').redo(); \n}"},"h1bee51638018e23":{"_id":"h1bee51638018e23","component":"vdbc51200e11z00","state":"click","action":"function click() { \n $('#designer-toolbar-item-undo').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('editor').undo(); \n}"},"t197d11eeee1e568":{"_id":"t197d11eeee1e568","component":"1dbc51200e116e6","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"g1dfae1d94d10ce1":{"_id":"g1dfae1d94d10ce1","component":"1dbc51200e116e5","state":"click","action":"function click() {\n $('#designer-toolbar-item-save').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').save();\n}"},"y1fd9e171d717b39":{"_id":"y1fd9e171d717b39","component":"1dbc51200e116e10","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-type.html', '_blank', true); \n}"},"w108111c7dc1ca6b":{"_id":"w108111c7dc1ca6b","component":"Workspace","state":"render","action":"function render() { \n var Editor = null,\n designer = null,\n editor = null;\n\n Editor = this.require('Editor');\n designer = this.require('designer');\n\n if (designer.isCordova()) {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'codemirror',\n 'context': 'type',\n 'editor': CodeMirror($('#designer-editor')[0], {\n lineNumbers: true,\n styleActiveLine: true,\n 'mode': 'application/json',\n 'theme': 'eclipse',\n 'tabSize': 2,\n 'autoCloseBrackets': true\n })\n });\n } else {\n editor = new Editor({\n '_id': 'editor',\n 'type': 'ace',\n 'context': 'type',\n 'editor': ace.edit('designer-editor')\n });\n }\n \n editor.render();\n}","useCoreAPI":false,"core":false},"t17faa1c1e816821":{"_id":"t17faa1c1e816821","component":"Designer","state":"render","action":"function render() {\n var id = '',\n systemId = '',\n system = '',\n type = '';\n \n // type\n this.require('state').type(window.location.href.split('.html')[0].split('/')[window.location.href.split('.html')[0].split('/').length - 1]);\n\n if (this.isCordova()) {\n this.updateCordovaContext();\n }\n\n // render\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('workspace').render();\n \n // get parameters\n id = decodeURIComponent(document.location.href.split('#')[1].split('?')[0]);\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n // set editors\n system = this.require('storage').get(systemId);\n this.require('factory').create(system);\n \n // extensions\n this.installExtensions();\n \n type = system.types[id];\n this.require('store').uuid(id);\n this.require('store').data(type);\n\n document.title = 'type ' + id + ' · system ' + system.name;\n\n this.require('editor').initValue(JSON.stringify(type, null, '\\t'), 2);\n\n this.require('router').update();\n \n // shorcuts\n this.addShortcuts();\n}","useCoreAPI":false,"core":false},"y14257199751564c":{"_id":"y14257199751564c","component":"Designer","state":"save","action":"function save() { \n var val = this.require('editor').getValue(),\n type = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n try {\n type = JSON.parse(val);\n } catch (e) {\n message.danger('Can not save your type: your type has an invalid structure.');\n return;\n }\n\n if (!type.name) {\n message.danger('The property \\'name\\' is missing.');\n return;\n }\n \n // clean name\n type.name = type.name.replace(/\\s|\\t/gi, '_')\n .replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '')\n .replace(/\\r|\\n/gi,'');\n\n if (!type.type) {\n message.danger('The property \\'type\\' is missing.');\n return;\n }\n\n if (type._id && type._id.indexOf(' ') !== -1) {\n message.danger('Invalid \\'_id\\'.
    Space is not authorized in the value of \\'_id\\'.');\n return;\n }\n\n this.require('store').data(type);\n\n // check if ID change\n if (this.require('store').uuid() !== this.require('store').data().name) {\n this.require('channel').$editorDeleteType(this.require('store').uuid());\n this.require('store').uuid(this.require('store').data().name);\n\n // update title\n document.title = 'type ' + this.require('store').uuid() + ' · ' + document.title.split('·')[1].trim();\n }\n\n this.require('channel').$editorUpdateType(this.require('store').uuid(), this.require('store').data());\n message.success('Type saved.');\n}","useCoreAPI":false,"core":false},"r1df8d1a54e1c14f":{"_id":"r1df8d1a54e1c14f","component":"w1667a15e2a1e2ef","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"b182a81e1c7173c3":{"_id":"b182a81e1c7173c3","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n id = '',\n href = '';\n\n id = decodeURIComponent(document.location.href.split('#')[1]);\n collection = document.location.href.split('#')[2];\n\n // update menubar\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n context = href.split('#')[href.split('#').length - 1];\n menubar[i].href = '#' + id + '#' + collection + '#' + context;\n }\n}","useCoreAPI":false,"core":false},"t1249a1a35319140":{"_id":"t1249a1a35319140","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config'),\n designer = this.require('designer'),\n state = this.require('state');\n \n if (designer.isCordova()) {\n state.messages().push(message);\n }\n \n this.require('storage').set('system-designer-message', message);\n \n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\n}","useCoreAPI":false,"core":false},"c1b2a41e5e61459c":{"_id":"c1b2a41e5e61459c","component":"_Channel","state":"init","action":"function init(conf) { \n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n}, true);\n}","useCoreAPI":false,"core":false},"a1eabd1ce561031c":{"_id":"a1eabd1ce561031c","component":"y174dd1c4fb187ed","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y133f11e82c1aad7":{"_id":"y133f11e82c1aad7","component":"k1423a15ea412f5d","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (this.require('factory').system()) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"x13d2a197b411642":{"_id":"x13d2a197b411642","component":"Designer","state":"addShortcuts","action":"function addShorcuts() { \n if (!this.isCordova()) {\n \tif (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event){\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null;\n \n switch (true) {\n // Command + O\n case key === 79 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n \t} else {\n document.body.addEventListener('keydown', function keydown(event){\n var key = event.which || event.keyCode;\n var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n \n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({'title':''});\n dialog.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this)); \n \t}\n }\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"1f8571164c179bf":{"_id":"1f8571164c179bf","html":"menu-action-version.html","position":10,"type":"type"}},"MenuHeader":{"1fb101b99813a14":{"_id":"1fb101b99813a14","html":"menu-header-type.html","type":"type"}},"MenuItem":{"1f1781882618104":{"_id":"1f1781882618104","name":"type","html":"menu-item-type.html","position":10,"type":"type","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"vdbc51200e11z03":{"_id":"vdbc51200e11z03","html":"toolbar-item-copy.html","position":50,"type":"type","platform":"electron"},"vdbc51200e11z04":{"_id":"vdbc51200e11z04","html":"toolbar-item-paste.html","position":60,"type":"type","platform":"electron"},"1dbc51200e116e10":{"_id":"1dbc51200e116e10","html":"toolbar-item-help.html","position":80,"type":"type","platform":"all"},"1dbc51200e116e5":{"_id":"1dbc51200e116e5","html":"toolbar-item-save.html","position":10,"type":"type","platform":"all"},"1dbc51200e116e6":{"_id":"1dbc51200e116e6","html":"toolbar-item-copyright.html","position":90,"type":"type","platform":"all"},"vdbc51200e11z00":{"_id":"vdbc51200e11z00","html":"toolbar-item-undo.html","position":20,"type":"type","platform":"all"},"vdbc51200e11z01":{"_id":"vdbc51200e11z01","html":"toolbar-item-redo.html","position":30,"type":"type","platform":"all"},"vdbc51200e11z02":{"_id":"vdbc51200e11z02","html":"toolbar-item-select-all.html","position":40,"type":"type","platform":"all"},"y174dd1c4fb187ed":{"_id":"y174dd1c4fb187ed","html":"toolbar-item-command.html","platform":"web","position":75,"type":"type"},"k1423a15ea412f5d":{"_id":"k1423a15ea412f5d","html":"toolbar-item-command.html","platform":"electron","position":75,"type":"type"}}},"_id":"w1667a15e2a1e2ef"}); \ No newline at end of file diff --git a/designer/scripts/system-designer.js b/designer/scripts/system-designer.js index 591916e..4e0db5b 100644 --- a/designer/scripts/system-designer.js +++ b/designer/scripts/system-designer.js @@ -1,3 +1,3 @@ // System Designer - Copyright 2019 Erwan Carriou // Licensed under the Apache License, Version 2.0 (the "License") -runtime.install({"name":"system-designer","master":true,"version":"3.5.2","description":"A Designer for Systems","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$designerSetSystem":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","messages":"property"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"],"designer":"property"},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]},"$designerSetSystem":{"params":[{"name":"system","type":"object","mandatory":false,"default":{}}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.2"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10","designer":{"type":"Designer","readOnly":true,"mandatory":false,"default":{}}},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}},"j1311d115381b738":{"_id":"j1311d115381b738","_name":"State","type":{"type":"string","readOnly":false,"mandatory":false,"default":""},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"z14cf91f7131c34d":{"_id":"z14cf91f7131c34d","component":"1dbc51300e11z17","state":"click","action":"function click() {\n $('#designer-toolbar-item-search').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var message = this.require('message');\n var Dialog = this.require('DialogSearch');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n}"},"a13b711adba1c7d4":{"_id":"a13b711adba1c7d4","component":"163a01b7ca1935c","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}"},"e137f915b1b15f90":{"_id":"e137f915b1b15f90","component":"163a01b7ca1935e","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}"},"p1087a100821fa03":{"_id":"p1087a100821fa03","component":"1dbc51200e116e3","state":"click","action":"function click() {\n $('#designer-toolbar-item-config').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogConfig = this.require('DialogConfig');\n\n DialogConfig = new DialogConfig({\n 'title': 'Configuration'\n });\n DialogConfig.show();\n DialogConfig.on('ok', function () {\n var message = this.require('message');\n\n this.hide();\n message.success('Configuration saved.');\n });\n}"},"y1163b139241a596":{"_id":"y1163b139241a596","component":"1dbc51200e116e11","state":"click","action":"function click() {\n $('#designer-toolbar-item-sync').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogSync = this.require('DialogSync');\n\n DialogSync = new DialogSync({\n 'title': 'GitHub'\n });\n DialogSync.show();\n DialogSync.on('ok', function () {\n if ($('#designer-dialog-sync-refresh').prop('checked')) {\n this.require('github').refresh();\n } else {\n this.require('github').push(\n $('#designer-dialog-sync-comments').val(),\n $('#designer-dialog-type-creation-hasHTML').prop('checked'),\n false,\n $('#designer-dialog-sync-options-log-level-select').val(),\n $('#designer-dialog-type-creation-hasPackage').prop('checked')\n );\n }\n this.hide();\n });\n}"},"o1ec561a54015768":{"_id":"o1ec561a54015768","component":"163a01b7ca1935d","state":"click","action":"function click() {\n $('#designer-toolbar-item-import').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogImportFile = this.require('DialogImportFile');\n\n var dialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n dialogImportFile.show();\n}"},"q178081a11712887":{"_id":"q178081a11712887","component":"13f70137b61b19b","state":"click","action":"function click() {\n var designer = this.require('designer'),\n message = this.require('message'),\n debugWindow = this.require('designer').debugWindow(),\n runWidow = this.require('designer').runWindow(),\n system = this.require('factory').system(),\n json = {},\n cleanJson = '',\n reg = null;\n\n $('#designer-toolbar-item-publish').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (system && system.name() !== 'default') {\n\n // force save befor running the app\n this.require('designer').save();\n\n\n switch(true) {\n // case of extension\n case system.name().indexOf('extension-') !== -1:\n json = this.require('factory').toJSON();\n\n cleanJson = JSON.stringify(json);\n reg = new RegExp(json._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + json._id);\n json = JSON.parse(cleanJson);\n runtime.stop(json._id);\n runtime.uninstall(json._id);\n runtime.install(json);\n this.require('menubar').render();\n this.require('toolbar').render();\n message.success('The extension has been installed.');\n break;\n \n // case of remote debugging\n case debugWindow && !debugWindow.closed:\n this.require('channel').$designerSetSystem(this.require('factory').toJSON());\n // TODO Refresh the page\n message.success('Running the system in the remote page...');\n break;\n\n // reload the running page\n case runWidow && !runWidow.closed:\n runWidow.close();\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n\n /*if (typeof require === 'undefined') {\n runWidow.document.location.reload();\n message.success('Running the system...');\n } else {\n // TODO \n // to reload when implemented in electron\n message.info('info: to run again the system, click the widow where your system is running and go to the menu \\'View > Refresh\\’.');\n }*/\n break;\n\n // we load for the first time the page\n default:\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n break;\n }\n } else {\n message.warning('There is no system to run.');\n }\n}","useCoreAPI":true},"k1a9e11cd571d17c":{"_id":"k1a9e11cd571d17c","component":"13a291c27f16314","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n switch (this.require('state').menu()) {\n case 'systems':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-system.html', '_blank', true); \n break;\n case 'schemas':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-schema.html', '_blank', true); \n break;\n case 'models':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/edit-a-model.html', '_blank', true); \n break;\n case 'types':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-type.html', '_blank', true); \n break;\n case 'behaviors':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-behavior.html', '_blank', true); \n break;\n case 'components':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-component.html', '_blank', true); \n break;\n case 'logs':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/run-your-system.html', '_blank', true);\n break;\n default:\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/quick-start.html', '_blank', true); \n break;\n }\n}"},"o1ff8e17e1c1bcd7":{"_id":"o1ff8e17e1c1bcd7","component":"13a291c27f16310","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"c15ea3176d5139e8":{"_id":"c15ea3176d5139e8","component":"10bcb1a0511e09f","state":"click","action":"function click() { \n $('#designer-toolbar-item-create').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message'),\n designer = this.require('designer');\n \n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n this.require('workspace').create();\n }\n }\n}"},"l19fda1461e1d86c":{"_id":"l19fda1461e1d86c","component":"Spaces","state":"clear","action":"function clear() { \n this.require('state').space('');\n $('#designer-spaces-items').empty();\n}","useCoreAPI":false,"core":false},"a16e02190b216769":{"_id":"a16e02190b216769","component":"Spaces","state":"render","action":"function render() { \n var item = null,\n items = [],\n components = [],\n systemItems = [],\n system = this.require('factory').system(),\n SpaceItem = this.require('SpaceItem'),\n spaceItem = null,\n space = '',\n id = '',\n domItems = document.getElementById('designer-spaces-items'),\n systemdomItems = document.getElementById('designer-spaces-system-items'),\n componentdomItems = document.getElementById('designer-spaces-components-items'),\n self = this,\n name = '',\n callback = null,\n modelsName = [],\n showComponents = false,\n modelName = '',\n componentId = '',\n fragment = '';\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n requestAnimationFrame(function () {\n $(item).removeClass('active');\n });\n }\n }\n\n function _findModel(compId, components) {\n var result = '',\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n $('#designer-spaces-help').empty();\n\n // update header and help\n switch (this.require('state').menu()) {\n case 'systems':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Systems';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-system.html').getHTML());\n break;\n case 'schemas':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Schemas';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-schemas.html').getHTML());\n break;\n case 'models':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-models.html').getHTML());\n break;\n case 'types':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Types';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-types.html').getHTML());\n break;\n case 'behaviors':\n $('#designer-spaces-spaces-system').show();\n $('#designer-spaces-spaces-components').show();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n document.getElementById('designer-spaces-system-header').innerHTML = 'System';\n document.getElementById('designer-spaces-components-header').innerHTML = 'Components';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-behaviors.html').getHTML());\n break;\n case 'components':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-components.html').getHTML());\n break;\n case 'logs':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Logs';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-logs.html').getHTML());\n break;\n default:\n break;\n }\n\n // update spaces\n // clear\n $('#designer-spaces-items').empty();\n $('#designer-spaces-system-items').empty();\n $('#designer-spaces-components-items').empty();\n if (system) {\n switch (this.require('state').menu()) {\n case 'systems':\n // items \n var systems = this.require('storage').get('system-designer-systems'),\n systemIds = [],\n length = 0,\n i = 0;\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system.name !== 'default') {\n spaceItem = new SpaceItem({\n 'name': system.name,\n 'uuid': system._id\n });\n \n items.push(spaceItem);\n }\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n \n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n this.items().forEach(function (item) {\n item.on('click', function () {\n var designer = this.require('designer'),\n system = this.require('storage').get(this.uuid()),\n System = this.require('System');\n \n if (system) {\n this.require('factory').create(system);\n }\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n });\n });\n\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n if (this.require('factory').system()) {\n if ($('#designer-space-' + this.require('factory').system().name()).length) {\n $('#designer-space-' + this.require('factory').system().name()).addClass('active');\n this.require('state').space(this.require('factory').system().name());\n }\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n }\n\n break;\n case 'schemas':\n // items \n for (name in system.schemas()) {\n spaceItem = new SpaceItem({\n 'name': system.schemas()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n \n case 'models':\n // items \n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n case 'types':\n // items\n for (name in system.types()) {\n spaceItem = new SpaceItem({\n 'name': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n break;\n case 'behaviors':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.items().reverse();\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n this.items().forEach(function (item) {\n modelsName.push(item.name());\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment); \n }\n \n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n // systems\n systemItems = []\n\n if (this.require('storage').get('system-designer-systems') && this.require('storage').get('system-designer-systems').systems.length) {\n if (this.require('factory').system().name() !== 'default') {\n spaceItem = new SpaceItem({\n 'name': this.require('factory').system().name(),\n 'uuid': this.require('factory').system().id()\n });\n systemItems.push(spaceItem);\n }\n }\n \n this.systems(systemItems);\n fragment = '';\n \n this.systems().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().unshift('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n systemdomItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = systemdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = systemdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.systems(i)));\n }\n\n space = this.require('state').space();\n if (modelsName.indexOf(space) !== -1) {\n showComponents = true;\n modelName = space;\n } else {\n modelName = _findModel(space, this.require('factory').system().components());\n if (modelName) {\n showComponents = true;\n }\n }\n\n if (showComponents) {\n\n // components\n components = [];\n\n // components\n for (id in system.components()[modelName]) {\n spaceItem = new SpaceItem({\n 'name': id,\n 'uuid': id\n });\n components.push(spaceItem);\n }\n\n this.components(components);\n\n // sort\n this.components().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.components().reverse();\n\n fragment = '';\n \n this.components().forEach(function (item) {\n modelsName.push(item.name());\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n componentdomItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = componentdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = componentdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.components(i)));\n }\n }\n\n // focus\n if (this.items().length > 0) {\n if ($('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).length) {\n $('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).addClass('active');\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n if (this.systems(0)) {\n this.require('state').space(this.systems(0).name());\n }\n }\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n if (this.systems(0)) {\n this.require('state').space(this.systems(0).name());\n }\n }\n\n break;\n \n case 'components':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n\n break;\n case 'logs':\n this.require('state').navigation().spaces([]);\n \n fragment = '';\n\n fragment = fragment + '
  • All logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-all');\n fragment = fragment + '
  • Error logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-error');\n fragment = fragment + '
  • Warning logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-warn');\n fragment = fragment + '
  • Info logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-info');\n fragment = fragment + '
  • Debug logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-debug');\n \n domItems.insertAdjacentHTML('beforeend', fragment);\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space('all');\n }\n }\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"d1cb2d156c513e03":{"_id":"d1cb2d156c513e03","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var json = '';\n reader.onload = function (event) {\n json += event.target.result;\n };\n reader.onloadend = function () {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n \n var DialogDropFile = that.require('DialogDropFile');\n \n if (!that.require('factory').system()) {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system.'\n });\n } else {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system or compose it with the current system.'\n });\n }\n \n DialogDropFile.data(sys);\n DialogDropFile.show();\n } else {\n that.require('message').warning('The file that you have dropped is not a valid system.');\n }\n } catch(e) {\n that.require('message').warning('The file that you have dropped is not a valid system.');\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\n}","useCoreAPI":false,"core":false},"v1090710e8e1d9f9":{"_id":"v1090710e8e1d9f9","component":"Workspace","state":"create","action":"function create() {\n var id = '',\n Dialog = null,\n dialog = null,\n factory = this.require('factory'),\n system = this.require('factory').system();\n\n switch (this.require('state').menu()) {\n case 'systems':\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n break;\n case 'schemas':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n }\n break;\n case 'models':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogModelCreation');\n dialog = new Dialog({\n 'title': 'Create a new model',\n });\n dialog.show();\n }\n break;\n case 'types':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogTypeCreation');\n dialog = new Dialog({\n 'title': 'Create a new type',\n });\n dialog.show();\n }\n break;\n case 'components':\n if (system && Object.keys(system).length) {\n var models = this.require('factory').system().models(),\n component = {},\n ModelComponent = null,\n modelComponent = null,\n modelName = '';\n\n modelName = this.require('state').space();\n\n if (typeof models[modelName] === 'undefined') {\n \n this.require('message-help').remove();\n\n component = this.require('factory').addComponent(modelName);\n\n ModelComponent = this.require('ModelComponent');\n\n modelComponent = new ModelComponent({\n title: component._id\n });\n modelComponent.model(modelName);\n modelComponent.uuid(component._id);\n modelComponent.document(JSON.parse(JSON.stringify(component)));\n modelComponent.content(JSON.stringify(component));\n\n modelComponent.render();\n\n // little effect\n $('#designer-component-' + component._id).hide();\n $('#designer-component-' + component._id).fadeIn(1000);\n\n this.require('designer').save();\n\n this.require('channel').$designerCreateComponent(modelName, component);\n this.require('message').success('Component created.');\n } else {\n this.require('message').warning('There is no schema. Create a schema before creating a component.');\n }\n }\n break;\n case 'behaviors':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogBehaviorCreation');\n dialog = new Dialog({\n 'title': 'Create a new behavior',\n });\n dialog.show();\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"f134d11639b1c4fe":{"_id":"f134d11639b1c4fe","component":"Workspace","state":"clear","action":"function clear() { \n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n \n jsPlumb.ready(function () {\n try {\n jsPlumb.deleteEveryEndpoint();\n } catch (e) {\n \n }\n });\n \n $('#designer-workspace').empty();\n}","useCoreAPI":false,"core":false},"i131bd1870a18e7a":{"_id":"i131bd1870a18e7a","component":"e89c617b6b15d28","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"l1b9611fc10168ec":{"_id":"l1b9611fc10168ec","component":"State","state":"logs","action":"function logs(value, type) { \n var html = '';\n var filter = this.require('state').space();\n var logNumber = 0;\n \n if (type === 'add') {\n if (this.require('state').menu() === 'logs') {\n switch (value.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n default:\n break;\n }\n \n document.querySelector('#designer-loug-output').insertAdjacentHTML('beforeend',\n html\n );\n } else {\n requestAnimationFrame(function() {\n // increment log number\n var logNumber = parseInt(document.querySelector('#designer-menu-item-logs-number').innerHTML, 10);\n document.querySelector('#designer-menu-item-logs-number').innerHTML = logNumber + 1;\n $('#designer-menu-item-logs-number').show();\n });\n }\n }\n}","useCoreAPI":false,"core":false},"p1d00311ad51ef9a":{"_id":"p1d00311ad51ef9a","component":"Designer","state":"welcome","action":"function welcome() { \n var Dialog = null,\n dialog = null,\n config = null;\n\n config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n\n if (typeof config.welcomeScreen === 'undefined') {\n Dialog = this.require('DialogWelcome');\n dialog = new Dialog({\n 'title': 'Welcome to System Designer'\n });\n dialog.show();\n dialog.on('ok', function ok() {\n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.welcomeScreen = false;\n this.require('storage').set('system-designer-config', config);\n this.hide();\n });\n }\n}","useCoreAPI":false,"core":false},"o12c7d1448a1dc16":{"_id":"o12c7d1448a1dc16","component":"Designer","state":"render","action":"function render() {\n var System = null,\n systemId = '',\n config = {};\n\n // message\n this.require('logger').on('warn', function warn(message) {\n this.require('message').warning(message);\n });\n this.require('logger').on('error', function error(message) {\n this.require('message').danger(message);\n });\n\n // extensions\n this.installExtensions();\n\n // system\n System = this.require('System');\n var systems = this.require('storage').get('system-designer-systems');\n\n // case of url\n switch (true) {\n case window.location.href.split('#').length > 1 && window.location.href.split('#')[1].length > 0:\n systemId = window.location.href.split('#')[1];\n if (this.require('storage').get(systemId)) {\n this.require('factory').create(this.require('storage').get(systemId));\n }\n break;\n default:\n if (systems && systems.systems && systems.systems.length && systems.systems[0].length) {\n systems.systems.sort(function (sysA, sysB) {\n var a = this.require('storage').get(sysA),\n b = this.require('storage').get(sysB),\n result = 0;\n\n if (a.name > b.name) {\n result = 1;\n }\n if (a.name < b.name) {\n result = -1;\n }\n return result;\n }.bind(this));\n\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n break;\n }\n\n this.welcome();\n\n this.require('router').start();\n\n if (typeof document.ontouchstart === 'undefined') {\n // resize event\n $(window).resize(function() {\n jsPlumb.repaintEverything();\n });\n } else {\n // orientation change event\n window.addEventListener('orientationchange', function() {\n setTimeout(function() {\n window.scrollTo(0, 0);\n if (typeof jsPlumb !== 'undefined') {\n jsPlumb.repaintEverything();\n }\n }, 100);\n });\n }\n\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('spaces').render();\n\n this.addShorcuts();\n\n // run messages if any\n this.runMessages(this.require('state').messages());\n this.require('state').messages([]);\n\n // install PWA\n window.addEventListener('beforeinstallprompt', (e) => {\n var config = runtime.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n if (typeof config.pwaInstalled === 'undefined' && config.welcomeScreen === false) {\n config.pwaInstalled = false;\n this.require('storage').set('system-designer-config', config);\n\n e.preventDefault();\n var Dialog = runtime.require('DialogInstallPWA');\n var dialog = new Dialog({ 'title': 'Install System Designer' });\n dialog.deferredPrompt(e);\n dialog.show();\n }\n });\n}","useCoreAPI":false,"core":false},"x196fc166ef17a85":{"_id":"x196fc166ef17a85","component":"Designer","state":"linkModel","action":"function linkModel(source, target) { \n jsPlumb.ready(function () {\n jsPlumb.setContainer('body');\n\n jsPlumb.connect({\n paintStyle: {\n stroke: '#7F949D',\n strokeWidth: 3\n },\n source: 'designer-model-panel-' + source,\n target: 'designer-model-panel-' + target,\n overlays: [\n ['Arrow', {\n location: 1\n }]\n ]\n }, {\n connector: ['Flowchart'],\n anchor: ['Left', 'Right'],\n endpoint: 'Blank'\n });\n });\n}","useCoreAPI":false,"core":false},"k13951153851cc3a":{"_id":"k13951153851cc3a","component":"Designer","state":"save","action":"function save() { \n var systems = this.require('storage').get('system-designer-systems'),\n system = this.require('factory').toJSON(),\n systemId = system._id;\n\n // save system\n this.require('storage').set(systemId, system);\n\n // save index\n if (!systems) {\n systems = { 'systems': [systemId] };\n } else {\n if (systems.systems.indexOf(systemId) === -1) {\n systems.systems.push(systemId);\n }\n }\n this.require('storage').set('system-designer-systems', systems);\n}","useCoreAPI":false,"core":false},"u1cf0e155fb1e53f":{"_id":"u1cf0e155fb1e53f","component":"Workspace","state":"render","action":"function render() { \n var ModelSystem = null,\n ModelSchema = null,\n ModelClass = null,\n modelSchema = null,\n ModelLog = null,\n sys = null,\n name = '',\n id = '',\n schemaId = '',\n modelclass = null,\n modellog = null,\n ModelType = null,\n type = null,\n ModelComponent = null,\n component = null,\n ModelBehavior = null,\n behavior = null,\n system = this.require('factory').system(),\n space = this.require('state').space(),\n menu = this.require('state').menu(),\n systemStore = {};\n parentId = '',\n parentsId = [],\n parents = null,\n systems = null,\n systemIds = [],\n i = 0,\n length = 0,\n title = 0,\n nbElement = 0;\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas()) {\n if (system.schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models()) {\n if (system.models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (system && system.name() !== 'default') {\n this.clear();\n\n window.scrollTo(0, 0);\n\n title = 'system ' + system.name();\n if (title !== document.title) {\n document.title = title;\n }\n\n switch (this.require('state').menu()) {\n case 'systems':\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n systemStore = this.require('storage').get(systemIds[i]);\n if (systemStore.name === space) {\n ModelSystem = this.require('ModelSystem');\n sys = new ModelSystem({\n 'title': systemStore.name\n });\n sys.uuid(systemStore._id);\n sys.document(JSON.parse(JSON.stringify(systemStore)));\n sys.content(JSON.stringify(systemStore));\n sys.render();\n }\n }\n\n if (space === '' && length > 0) {\n this.require('message').warning('System not found.');\n }\n\n break;\n case 'schemas':\n if (space) {\n for (id in system.schemas()) {\n if (system.schemas()[id]._id === space) {\n ModelSchema = this.require('ModelSchema');\n\n // create parent if any\n parentsId = [];\n if (system.schemas()[id]._inherit) {\n parents = system.schemas()[id]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n parentId = _getSchemaId(parents[i]);\n\n modelSchema = new ModelSchema({\n 'title': parents[i]\n });\n \n if (parents[i] !== system.schemas()[id]._name) {\n if (parents[i] === '_Component') {\n parentId = \"111df11e2b19fde\";\n \n var schemaRuntime = {\n \"_id\": \"_Component\",\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": \"property\",\n \"classInfo\": \"method\",\n \"init\": \"method\",\n \"destroy\": \"method\",\n \"on\": \"method\",\n \"off\": \"method\",\n \"require\": \"method\",\n \"error\": \"event\"\n };\n \n modelSchema.document(schemaRuntime);\n modelSchema.content(JSON.stringify(schemaRuntime));\n parentsId.push(parentId);\n modelSchema.uuid(parentId);\n } else {\n if (system.schemas()[_getSchemaId(parents[i])]) {\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[_getSchemaId(parents[i])])));\n modelSchema.content(JSON.stringify(system.schemas()[_getSchemaId(parents[i])]));\n parentsId.push(_getSchemaId(parents[i]));\n modelSchema.uuid(_getSchemaId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelSchema.uuid(parents[i]);\n }\n }\n modelSchema.render();\n }\n }\n\n modelSchema = new ModelSchema({\n 'title': system.schemas()[id]._name\n });\n modelSchema.uuid(id);\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[id])));\n modelSchema.content(JSON.stringify(system.schemas()[id]));\n modelSchema.editable(true);\n modelSchema.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'models':\n if (space) {\n for (id in system.models()) {\n if (system.models()[id]._id === space) {\n ModelClass = this.require('ModelClass');\n\n // create parent if any\n // parents are search from the schema\n schemaId = _getSchemaId(system.models()[id]._name);\n parentsId = [];\n if (schemaId && system.schemas()[schemaId]._inherit) {\n parents = system.schemas()[schemaId]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n\n parentId = _getSchemaId(parents[i]);\n\n modelclass = new ModelClass({\n 'title': parents[i]\n });\n\n if (parents[i] === '_Component') {\n parentId = '123751cb591de26';\n\n var modelRuntime = {\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": {\n \"description\": \"get the unique ID of a component\",\n \"type\": \"string\",\n \"readOnly\": true,\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"classInfo\": {\n \"description\": \"get the model of the component\",\n \"result\": \"_ClassInfo\"\n },\n \"init\": {\n \"description\": \"action to do when the component is created\",\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n },\n \"destroy\": {\n \"description\": \"action to do when the component is destroyed\",\n \"params\": []\n },\n \"on\": {\n \"description\": \"add a behavior to a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"action\",\n \"type\": \"function\"\n },\n {\n \"name\": \"useCoreAPI\",\n \"type\": \"boolean\",\n \"mandatory\": false\n },\n {\n \"name\": \"isCore\",\n \"type\": \"boolean\",\n \"mandatory\": false\n }\n ],\n \"result\": \"string\"\n },\n \"off\": {\n \"description\": \"remove a behavior from a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"behaviorId\",\n \"type\": \"string\",\n \"mandatory\": false\n }]\n },\n \"require\": {\n \"description\": \"require a component\",\n \"params\": [{\n \"name\": \"id\",\n \"type\": \"string\"\n }],\n \"result\": \"_Component\"\n },\n \"error\": {\n \"description\": \"action to do when an error happened\",\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n }\n };\n\n modelclass.document(modelRuntime);\n modelclass.content(JSON.stringify(modelRuntime));\n parentsId.push(parentId);\n modelclass.uuid(parentId);\n } else {\n if (system.models()[_getModelId(parents[i])]) {\n modelclass.document(JSON.parse(JSON.stringify(system.models()[_getModelId(parents[i])])));\n modelclass.content(JSON.stringify(system.models()[_getModelId(parents[i])]));\n parentsId.push(_getModelId(parents[i]));\n modelclass.uuid(_getModelId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelclass.uuid(parentId);\n }\n }\n modelclass.render();\n }\n\n modelclass = new ModelClass({\n 'title': system.models()[id]._name\n });\n modelclass.uuid(id);\n modelclass.document(JSON.parse(JSON.stringify(system.models()[id])));\n modelclass.content(JSON.stringify(system.models()[id]));\n modelclass.editable(true);\n modelclass.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'types':\n if (space) {\n for (name in system.types())\n if (system.types()[name].name === space) {\n ModelType = this.require('ModelType');\n type = new ModelType({\n 'title': name\n });\n type.uuid(name);\n type.document(JSON.parse(JSON.stringify(system.types()[space])));\n type.content(JSON.stringify(system.types()[space]));\n type.render();\n }\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'components':\n var nbComponents = 0;\n if (space) {\n if (this.require('state').component()) {\n name = this.require('state').component();\n if (system.components()[space] && system.components()[space][name]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n } else {\n this.require('message-help').render();\n }\n } else {\n for (name in system.components()[space]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n nbComponents = nbComponents + 1;\n \n if (nbComponents === 50) {\n this.require('message').warning('For performance reason you will only see the first 50 components.');\n break;\n }\n }\n \n if (system.components()) {\n if (system.components()[space]) {\n if (Object.keys(system.components()[space]).length === 0) {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n }\n } else {\n if (Object.keys(system.components()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'behaviors':\n if (space) {\n name = this.require('state').component();\n var behaviorDef = {};\n var behaviorsId = Object.keys(system.behaviors());\n var systemName = this.require('factory').system().name();\n var systemId = this.require('factory').system().id();\n ModelBehavior = this.require('ModelBehavior');\n \n behaviorsId.forEach(function(id) {\n behaviorDef = system.behaviors()[id];\n if (behaviorDef.component === space) {\n if ((name && behaviorDef.state === name) || name === '') {\n behavior = new ModelBehavior({\n 'uuid': system.behaviors()[id]._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n\n // system\n if (space === systemName) {\n if (behaviorDef.component === systemId) {\n behavior = new ModelBehavior({\n 'uuid': behaviorDef._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n }.bind(this));\n \n if (nbElement === 0) {\n this.require('message-help').render();\n } else {\n Prism.highlightAll();\n }\n } else {\n if (Object.keys(system.behaviors()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'logs':\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n $('#designer-menu-item-logs-number').hide();\n \n ModelLog = this.require('ModelLog');\n\n modelLog = new ModelLog();\n modelLog.render();\n\n break;\n default:\n break;\n }\n } else {\n\n document.title = '';\n document.title = 'System Designer';\n \n this.require('message-help').render();\n \n if (system && system.name() === 'default') {\n this.require('message').warning('System not found: the system has been deleted.');\n } else {\n systems = this.require('storage').get('system-designer-systems');\n if (systems && systems.systems && systems.systems.length) {\n this.require('message').warning('System not found: click on the Systems tab to reload your context.');\n }\n }\n }\n}","useCoreAPI":false,"core":false},"s1876e1b64c1251e":{"_id":"s1876e1b64c1251e","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n collection = '',\n href = '',\n context = '',\n space = '',\n schemaName = '',\n schemaId = '',\n modelName = '',\n modelId = '';\n \n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelName(id, models) {\n var result = '',\n modelId = '';\n\n for (modelId in models) {\n if (modelId === id) {\n result = models[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaName(id, schemas) {\n var result = '',\n schemaId = '';\n\n for (schemaId in schemas) {\n if (schemaId === id) {\n result = schemas[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getCollection(href) {\n var result = '';\n\n if (href.split('#').length === 2) {\n result = href.split('#')[1];\n }\n if (href.split('#').length > 2) {\n result = href.split('#')[2];\n }\n\n result = result.split('#')[0];\n result = result.trim();\n\n return result;\n }\n\n context = this.require('state').menu();\n space = this.require('state').space();\n\n switch (context) {\n case 'schemas':\n if (this.require('factory').system()) {\n if (space) {\n schemaName = _getSchemaName(space, this.require('factory').system().schemas());\n modelId = _getModelId(schemaName, this.require('factory').system().models());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n if (collection === 'behaviors' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'models':\n if (this.require('factory').system()) {\n if (space) {\n modelName = _getModelName(space, this.require('factory').system().models());\n schemaId = _getSchemaId(modelName, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'components' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n if (collection === 'behaviors' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'behaviors':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'components':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'behaviors' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n default:\n if (this.require('factory').system()) {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n }\n}","useCoreAPI":false,"core":false},"a1e92e1b7d6162ab":{"_id":"a1e92e1b7d6162ab","component":"Router","state":"start","action":"function start() { \n var that = this;\n \n window.onhashchange = function (e) {\n var arr = window.location.href.split('#'),\n system = '',\n collection = 'systems',\n component = '',\n i = 0,\n length = 0,\n item = null,\n domItems = null,\n System = that.require('System'),\n systems = that.require('storage').get('system-designer-systems');\n\n if (arr.length > 1) {\n system = arr[1];\n system = system.split('?')[0];\n }\n\n if (arr.length > 2) {\n collection = arr[2];\n collection = collection.split('?')[0];\n }\n\n if (arr.length > 3) {\n component = arr[3];\n component = component.split('?')[0];\n }\n\n if (arr.length > 4) {\n that.require('state').component(arr[4].split('?')[0]);\n } else {\n that.require('state').component('');\n }\n \n if (arr.length > 1 && system) {\n that.require('factory').create(that.require('storage').get(system));\n } else {\n if (systems && systems.systems && systems.systems.length) {\n that.require('factory').create(that.require('storage').get(systems.systems[0]));\n }\n }\n \n that.require('state').space(decodeURIComponent(component));\n that.require('state').menu(decodeURIComponent(collection));\n\n // focus\n domItems = document.getElementById('designer-menubar-items');\n length = that.require('menubar').items().length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n for (i = 0; i < length; i++) {\n if (that.require('menubar').items(i).name() === collection) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n\n that.update();\n };\t\n}","useCoreAPI":false,"core":false},"v10ccc18f431a78e":{"_id":"v10ccc18f431a78e","component":"State","state":"menu","action":"function menu(value) { \n jsPlumb.ready(function () {\n try {\n jsPlumb.deleteEveryEndpoint();\n } catch (e) {\n }\n });\n\n this.require('spaces').render();\n this.require('workspace').clear();\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"n17df1112301e0cf":{"_id":"n17df1112301e0cf","component":"State","state":"space","action":"function space(value) { \n if (this.menu() === 'systems') {\n this.require('router').update();\n }\n}","useCoreAPI":false,"core":false},"j1fc1a152e61a7b9":{"_id":"j1fc1a152e61a7b9","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config');\n // message for other windows\n this.require('storage').set('system-designer-message', message);\n\n // message for client debug\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(message), '*');\n }\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"s11b84108ec12d82":{"_id":"s11b84108ec12d82","component":"_Channel","state":"$appLogDebug","action":"function $appLogDebug(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'debug',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'debug: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"s1274812bab1ab3d":{"_id":"s1274812bab1ab3d","component":"_Channel","state":"$appLogInfo","action":"function $appLogInfo(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'info',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'info: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"b1c5cb1ee0b195fc":{"_id":"b1c5cb1ee0b195fc","component":"_Channel","state":"$appLogWarn","action":"function $appLogWarn(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'warn',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'warning: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').warning(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"i1b8de1d60316328":{"_id":"i1b8de1d60316328","component":"_Channel","state":"$appLogError","action":"function $appLogError(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'error',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'error: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').danger(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"h1ad061990d1bcc5":{"_id":"h1ad061990d1bcc5","component":"_Channel","state":"$editorUpdateType","action":"function $editorUpdateType(id, type) { \n this.require('factory').updateType(id, type);\n\n this.require('designer').save();\n\n this.require('state').space(type.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"h1275e1a9791051a":{"_id":"h1275e1a9791051a","component":"_Channel","state":"$editorDeleteType","action":"function $editorDeleteType(id) { \n var dbTypes = [],\n type = null;\n\n dbTypes = this.require('db').collections().ModelType.find({\n 'uuid': id\n });\n if (dbTypes.length) {\n type = this.require(dbTypes[0]._id);\n if (type) {\n type.hide();\n type.destroy();\n }\n }\n\n this.require('factory').deleteType(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1b3231dd52189ee":{"_id":"u1b3231dd52189ee","component":"_Channel","state":"$editorUpdateSchemaName","action":"function $editorUpdateSchemaName(name, id) { \n this.require('factory').updateSchemaName(name, id);\n \n this.require('designer').save();\t\n}","useCoreAPI":false,"core":false},"w17e86178ff1ac10":{"_id":"w17e86178ff1ac10","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var oldModel = this.require('factory').getGeneratedModel(schema._name);\n schemas = this.require('factory').system().schemas(),\n models = null,\n model = null,\n modelId = '';\n\n this.require('factory').syncModel(schema);\n \n this.require('designer').save();\n \n this.require('factory').updateSchema(id, schema);\n \n this.require('designer').save();\n\n // sync other components\n models = this.require('factory').system().models();\n for (modelId in models) {\n if (models[modelId]._name !== schema._name) {\n model = models[modelId];\n this.require('factory').syncComponent(model, oldModel, true);\n }\n }\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"f14bae11650167a7":{"_id":"f14bae11650167a7","component":"_Channel","state":"$editorUpdateSchemaId","action":"function $editorUpdateSchemaId(oldId, newId) { \n this.require('factory').updateSchemaId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"n1cd861eb1d1d0a5":{"_id":"n1cd861eb1d1d0a5","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n var oldModel = this.require('factory').getGeneratedModel(model._name);\n\n this.require('factory').updateModel(id, model);\n\n this.require('designer').save();\n\n this.require('factory').syncBehavior(model);\n \n this.require('designer').save();\n \n this.require('factory').syncComponent(model, oldModel, true);\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n \n $(function () {\n $('[role=\"tooltip\"]').hide();\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"n1a1a113960107dd":{"_id":"n1a1a113960107dd","component":"_Channel","state":"$editorUpdateModelId","action":"function $editorUpdateModelId(oldId, newId) { \n this.require('factory').updateModelId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1219c18bd215028":{"_id":"m1219c18bd215028","component":"_Channel","state":"$designerUpdateBehavior","action":"function $designerUpdateBehavior(id, behavior) { \n this.require('factory').udpdateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"g1271811dd61f96f":{"_id":"g1271811dd61f96f","component":"_Channel","state":"$editorDeleteBehavior","action":"function $editorDeleteBehavior(id) { \n var dbBehaviors = [],\n behavior = null;\n\n dbBehaviors = this.require('db').collections().ModelBehavior.find({\n 'uuid': id\n });\n if (dbBehaviors.length) {\n behavior = this.require(dbBehaviors[0]._id);\n if (behavior) {\n behavior.hide();\n behavior.destroy();\n }\n }\n\n this.require('factory').deleteBehavior(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1433e1b8e71050a":{"_id":"m1433e1b8e71050a","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n this.require('factory').overwriteComponent(id, collection, component);\n\n this.require('designer').save();\n\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"e1acfa1989b122ec":{"_id":"e1acfa1989b122ec","component":"_Channel","state":"$editorDeleteComponent","action":"function $editorDeleteComponent(id, collection) { \n var models = [],\n model = null;\n\n models = this.require('db').collections().ModelComponent.find({\n 'uuid': id\n });\n if (models.length) {\n model = this.require(models[0]._id);\n if (model) {\n model.hide();\n model.destroy();\n }\n }\n\n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"x11f721f8111c41a":{"_id":"x11f721f8111c41a","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n this.require('factory').updateSystem(id, system);\n \n this.require('designer').save();\n\n this.require('state').space(system.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"d180f31873a19ef7":{"_id":"d180f31873a19ef7","component":"_Channel","state":"$appLoadSystem","action":"function $appLoadSystem(system) { \n var Dialog = null,\n dialog = null,\n message = this.require('message');\n\n if (system.name) {\n if (system.name !== 'designer-runtime') {\n Dialog = this.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you want to import the system ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n }\n } else {\n message.warning('There is no system to import.');\n }\n}","useCoreAPI":false,"core":false},"r1318213d401b598":{"_id":"r1318213d401b598","component":"_Channel","state":"$runtimeCreateComponent","action":"function $runtimeCreateComponent(collection, component) { \n this.require('factory').createComponent(collection, component);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\t\n}","useCoreAPI":false,"core":false},"a125ea107d41f237":{"_id":"a125ea107d41f237","component":"_Channel","state":"$runtimeDeleteComponent","action":"function $runtimeDeleteComponent(id, collection) { \n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"n1636d1853518a09":{"_id":"n1636d1853518a09","component":"_Channel","state":"$runtimeUpdateComponent","action":"function $runtimeUpdateComponent(id, collection, field, value) { \n this.require('factory').updateComponent(id, collection, field, value);\n \n this.require('designer').save();\n \n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"v165f81ca0d1bd5f":{"_id":"v165f81ca0d1bd5f","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var dbSchemas = [],\n schema = null;\n\n dbSchemas = this.require('db').collections().ModelSchema.find({\n 'uuid': id\n });\n if (dbSchemas.length) {\n schema = this.require(dbSchemas[0]._id);\n if (schema) {\n schema.hide();\n schema.destroy();\n }\n }\n\n this.require('factory').deleteSchema(id, false);\n \n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1a9411d65313eb8":{"_id":"u1a9411d65313eb8","component":"_Channel","state":"$editorUpdateBehavior","action":"function $editorUpdateBehavior(id, behavior) { \n this.require('factory').updateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"s192131208d1553f":{"_id":"s192131208d1553f","component":"_Channel","state":"init","action":"function init(conf) { \n window.addEventListener('message', function message(event) {\n var data = null,\n config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n data = JSON.parse(event.data);\n if (data &&\n typeof data.event !== 'undefined' &&\n typeof data.from !== 'undefined' &&\n typeof data.data !== 'undefined') {\n $db._Message.insert(data);\n }\n }.bind(this), false);\n\n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(obj['system-designer-message'].newValue), '*');\n }\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":true,"core":false},"i1fa311dc26116f8":{"_id":"i1fa311dc26116f8","component":"y187401decb196c4","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"f1ae6e164301b982":{"_id":"f1ae6e164301b982","component":"x1371910b7812e58","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"q141da1eb5d1916b":{"_id":"q141da1eb5d1916b","component":"g12f9e166c71cf91","state":"click","action":"function click() {\n $('#designer-toolbar-item-extension').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogExtension = this.require('DialogExtension');\n\n DialogExtension = new DialogExtension({\n 'title': 'Manage your extensions'\n });\n DialogExtension.show();\n}","useCoreAPI":false,"core":false},"k1f66b12b5f1b625":{"_id":"k1f66b12b5f1b625","component":"l1f2871e69b1b85e","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1eaaf1fe0719457":{"_id":"y1eaaf1fe0719457","component":"_Channel","state":"$editorUpdateComponentId","action":"function $editorUpdateComponentId(oldId, newId) { \n this.require('factory').updateComponentId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"w1875419b271fb1c":{"_id":"w1875419b271fb1c","component":"Designer","state":"addShorcuts","action":"function addShorcuts() {\n if (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event) {\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null,\n position = 0;\n\n switch (true) {\n // Command + O\n case key === 79 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({ 'title': '' });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + F\n case key === 70 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + '+'\n case (key === 187 || key === 43) && command:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + I\n case key === 73 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n\n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + E\n case key === 69 && command && !this.isCordova():\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ->\n case key === 39 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + <-\n case key === 37 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length - 1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + v\n case key === 40 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ^\n case key === 38 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + Enter\n case key === 13 && command:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Enter \n case key === 13 && !command:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + D\n case key === 68 && command && !this.isCordova():\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n } else {\n document.body.addEventListener('keydown', function keydown(event) {\n var message = this.require('message'),\n key = event.which || event.keyCode,\n ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n dialog = null,\n Dialog = null;\n\n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({ 'title': '' });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + F\n case key === 70 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + '+' \n case (key === 187 || key === 43) && ctrl:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + I\n case key === 73 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n\n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + E\n case key === 69 && ctrl && !this.isCordova():\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ->\n case key === 39 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + <-\n case key === 37 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length - 1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + v\n case key === 40 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ^\n case key === 38 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + Enter\n case key === 13 && ctrl:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Enter \n case key === 13 && !ctrl:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + D\n case key === 68 && ctrl && !this.isCordova():\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n }\n\n}","useCoreAPI":false,"core":false},"q1e05f1c28c13d04":{"_id":"q1e05f1c28c13d04","component":"Designer","state":"runMessages","action":"function runMessages(messages) { \n messages.forEach(function (message) {\n if (message && message.event && message.event.indexOf('$system') === -1) {\n $db._Message.insert(message);\n }\n });\t\n}","useCoreAPI":true,"core":false},"c107c51c3091756f":{"_id":"c107c51c3091756f","component":"o195831c8251b34e","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n}","useCoreAPI":false,"core":false},"v173801bd85122c0":{"_id":"v173801bd85122c0","component":"t1bcd213629187e0","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\t\n}","useCoreAPI":false,"core":false},"d1128a15dc117e6f":{"_id":"d1128a15dc117e6f","component":"j1b4981736918b41","state":"click","action":"function click() { \n window.history.back();\t\n}","useCoreAPI":false,"core":false},"t114671df7c16805":{"_id":"t114671df7c16805","component":"u18d911723019b96","state":"click","action":"function click() { \n window.history.forward();\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.2"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.2"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages threw a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"j1b4981736918b41":{"_id":"j1b4981736918b41","html":"menu-action-back.html","position":10,"type":"designer"},"u18d911723019b96":{"_id":"u18d911723019b96","html":"menu-action-forward.html","position":20,"type":"designer"}},"MenuHeader":{"1fb101b99813a12":{"_id":"1fb101b99813a12","html":"menu-header.html","type":"designer"}},"MenuItem":{"14f481302c106e6":{"_id":"14f481302c106e6","name":"models","html":"menu-item-models.html","position":20,"type":"designer","platform":"all"},"14f481302c106e7":{"_id":"14f481302c106e7","name":"logs","html":"menu-item-logs.html","position":60,"type":"designer","platform":"all"},"154dd1323f1ffg0a":{"_id":"154dd1323f1ffg0a","name":"systems","html":"menu-item-system.html","position":10,"type":"designer","platform":"all"},"154dd1323f1ffg1a":{"_id":"154dd1323f1ffg1a","name":"schemas","html":"menu-item-schemas.html","position":10,"type":"designer","platform":"all"},"19ec81ce751e196":{"_id":"19ec81ce751e196","name":"components","html":"menu-item-components.html","position":50,"type":"designer","platform":"all"},"1eb9d188b11824c":{"_id":"1eb9d188b11824c","name":"behaviors","html":"menu-item-behaviors.html","position":40,"type":"designer","platform":"all"},"1fd911618e18ea9":{"_id":"1fd911618e18ea9","name":"types","html":"menu-item-types.html","position":30,"type":"designer","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc51300e11z17":{"_id":"1dbc51300e11z17","html":"toolbar-item-search.html","position":35,"type":"designer","platform":"all"},"163a01b7ca1935c":{"_id":"163a01b7ca1935c","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"web"},"163a01b7ca1935e":{"_id":"163a01b7ca1935e","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"web"},"10bcb1a0511e09f":{"_id":"10bcb1a0511e09f","html":"toolbar-item-create.html","position":20,"type":"designer","platform":"all"},"13a291c27f16310":{"_id":"13a291c27f16310","html":"toolbar-item-copyright.html","position":90,"type":"designer","platform":"all"},"13a291c27f16314":{"_id":"13a291c27f16314","html":"toolbar-item-help.html","position":80,"type":"designer","platform":"all"},"13f70137b61b19b":{"_id":"13f70137b61b19b","html":"toolbar-item-publish.html","position":30,"type":"designer","platform":"all"},"163a01b7ca1935d":{"_id":"163a01b7ca1935d","html":"toolbar-item-import.html","position":45,"type":"designer","platform":"all"},"1dbc51200e116e11":{"_id":"1dbc51200e116e11","html":"toolbar-item-sync.html","position":65,"type":"designer","platform":"all"},"1dbc51200e116e3":{"_id":"1dbc51200e116e3","html":"toolbar-item-config.html","position":70,"type":"designer","platform":"all"},"y187401decb196c4":{"_id":"y187401decb196c4","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"electron"},"x1371910b7812e58":{"_id":"x1371910b7812e58","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"electron"},"g12f9e166c71cf91":{"_id":"g12f9e166c71cf91","html":"toolbar-item-extension.html","platform":"all","position":67,"type":"designer"},"l1f2871e69b1b85e":{"_id":"l1f2871e69b1b85e","html":"toolbar-item-command.html","platform":"all","position":37,"type":"designer"},"o195831c8251b34e":{"_id":"o195831c8251b34e","html":"toolbar-item-diagram.html","platform":"web","position":38,"type":"designer"},"t1bcd213629187e0":{"_id":"t1bcd213629187e0","html":"toolbar-item-diagram.html","platform":"electron","position":38,"type":"designer"}}},"_id":"e89c617b6b15d28"}); \ No newline at end of file +runtime.install({"name":"system-designer","master":true,"version":"3.5.3","description":"A Designer for Systems","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"$editorUpdateSystem":"event","$editorUpdateSchema":"event","$editorUpdateSchemaId":"event","$editorUpdateSchemaName":"event","$editorUpdateModel":"event","$editorUpdateModelId":"event","$editorUpdateType":"event","$editorDeleteType":"event","$editorUpdateBehavior":"event","$editorDeleteBehavior":"event","$editorUpdateComponent":"event","$editorUpdateComponentId":"event","$editorDeleteComponent":"event","$appLogDebug":"event","$appLogInfo":"event","$appLogWarn":"event","$appLogError":"event","$appLoadSystem":"event","$designerSync":"event","$designerCreateBehavior":"event","$designerCreateComponent":"event","$designerCreateType":"event","$designerCreateSchema":"event","$designerCreateModel":"event","$designerDeleteSchema":"event","$designerDeleteModel":"event","$designerDeleteType":"event","$designerDeleteBehavior":"event","$designerDeleteComponent":"event","$designerUpdateComponent":"event","$designerUpdateModel":"event","$designerUpdateBehavior":"event","send":"event","$designerSetSystem":"event","$runtimeCreateComponent":"event","$runtimeDeleteComponent":"event","$runtimeUpdateComponent":"event"},"h1544a15cd115619":{"_name":"CSS","source":"property","_id":"h1544a15cd115619"},"o1ead8184af1a83e":{"_name":"Designer","_inherit":["_Component"],"version":"property","runWindow":"property","debugWindow":"property","linkModel":"method","save":"method","saveCordova":"method","saveAs":"method","welcome":"method","open":"method","render":"event","isCordova":"method","isElectron":"method","isMac":"method","updateCordovaContext":"method","runMessages":"method","installExtensions":"method","addShorcuts":"method","_id":"o1ead8184af1a83e","messages":"property"},"v123b51abbb18712":{"_id":"v123b51abbb18712","_name":"Diagram","_inherit":["_Component"],"data":"property","ref":"property","zoom":"property","render":"method"},"n1a57f14f7e1d5fe":{"_name":"Dialog","_inherit":["_Component"],"title":"property","message":"property","data":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","_id":"n1a57f14f7e1d5fe"},"r1ddda1abc81d3ae":{"_name":"DialogCopyright","_inherit":["Dialog"],"_id":"r1ddda1abc81d3ae"},"j1dd971e4e417dc0":{"_name":"DialogBehaviorCreation","_inherit":["Dialog"],"_id":"j1dd971e4e417dc0"},"z1cebc15af210ffd":{"_name":"DialogComponentCreation","_inherit":["Dialog"],"_id":"z1cebc15af210ffd"},"y18a2615cad1374d":{"_name":"DialogConfig","_inherit":["Dialog"],"_id":"y18a2615cad1374d"},"w1b40b10be812656":{"_name":"DialogDropFile","_inherit":["Dialog"],"_id":"w1b40b10be812656"},"w143aa1a8401eb92":{"_name":"DialogExport","_inherit":["Dialog"],"_id":"w143aa1a8401eb92"},"n1c79a1da261e02e":{"_name":"DialogImport","_inherit":["Dialog"],"_id":"n1c79a1da261e02e"},"c1758d13d20146d4":{"_name":"DialogImportFile","_inherit":["Dialog"],"mergeSystem":"event","importSystem":"event","_id":"c1758d13d20146d4"},"t13c8d1b4271338c":{"_name":"DialogModelCreation","_inherit":["Dialog"],"_id":"t13c8d1b4271338c"},"z19abb1de8815574":{"_name":"DialogComponentInfo","_inherit":["Dialog"],"_id":"z19abb1de8815574"},"b1cad1118451b9d7":{"_name":"DialogSchemaCreation","_inherit":["Dialog"],"_id":"b1cad1118451b9d7"},"e1c0cd11f9210181":{"_name":"DialogSearch","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property","_id":"e1c0cd11f9210181"},"v112c0137f31f448":{"_name":"DialogShare","_inherit":["Dialog"],"_id":"v112c0137f31f448"},"j1a5781d076127b4":{"_name":"DialogSync","_inherit":["Dialog"],"_id":"j1a5781d076127b4"},"y1cc6f1fdc415f97":{"_name":"DialogSystemCreation","_inherit":["Dialog"],"_id":"y1cc6f1fdc415f97"},"z15c55119a7160f3":{"_name":"DialogTypeCreation","_inherit":["Dialog"],"_id":"z15c55119a7160f3"},"g1db25176311401d":{"_name":"DialogWelcome","_inherit":["Dialog"],"_id":"g1db25176311401d"},"m1b56110321128fb":{"_id":"m1b56110321128fb","_name":"DialogExtension","_inherit":["Dialog"],"add":"method","remove":"method"},"e1d0301185e17e58":{"_id":"e1d0301185e17e58","_name":"DialogCommand","_inherit":["Dialog"],"filter":"property","currentSelection":"property","nbResult":"property"},"k16ab6191c412fea":{"_id":"k16ab6191c412fea","_name":"DialogDelete","_inherit":["Dialog"]},"b1a8ae1c3f113625":{"_id":"b1a8ae1c3f113625","_name":"DialogDropDiagram","_inherit":["Dialog"]},"f1d18452-66e4-4d67-a370-c83dd9437d83":{"_id":"f1d18452-66e4-4d67-a370-c83dd9437d83","_name":"DialogInstallPWA","_inherit":["Dialog"],"deferredPrompt":"property"},"1a3811dc79129d0":{"_id":"1a3811dc79129d0","_name":"Editor","_inherit":["_Component"],"editor":"property","type":"property","context":"property","render":"method","initValue":"method","getValue":"method","setValue":"method","setEditor":"method","undo":"method","redo":"method","selectAll":"method","copy":"method","paste":"method"},"v1dfff1f04618899":{"_id":"v1dfff1f04618899","_name":"Export","_inherit":["_Component"],"toJSON":"method","toHTML":"method","toJavaScript":"method","toNode":"method","toGraphviz":"method"},"x15866118f7110a3":{"_id":"x15866118f7110a3","_name":"Extension","_inherit":["_Component"],"source":"property","isCore":"property","installed":"property"},"13bdf1ff1815d7c":{"_id":"13bdf1ff1815d7c","_name":"Github","_inherit":["_Component"],"refresh":"method","push":"method","merge":"method"},"p181111d5c01f97b":{"_name":"HTML","source":"property","_id":"p181111d5c01f97b","_inherit":["_Component"],"render":"method","getHTML":"method"},"a77b5281-cd56-477a-8201-c2ffdfe14317":{"_id":"a77b5281-cd56-477a-8201-c2ffdfe14317","_name":"Strings","_inherit":["_Component"],"help_systems":"property","help_schemas":"property","help_models":"property","help_types":"property","help_behaviors":"property","help_components":"property","help_logs":"property"},"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352":{"_id":"c452eff3-f0f1-4dd5-ad8d-b5a3ec521352","_name":"Internationalization","_inherit":["_Component"],"get":"method","locale":"property"},"w10edc1dd24108d1":{"_name":"JS","source":"property","_id":"w10edc1dd24108d1","_inherit":["_Component"]},"r1bacb1740a1fc45":{"_name":"JSON","source":"property","_id":"r1bacb1740a1fc45","_inherit":["_Component"],"platform":"property"},"g1f6ce17a5713f1d":{"_id":"g1f6ce17a5713f1d","_name":"Language","_inherit":["_Component"],"target":"property","createBehaviorBody":"method","createBehavior":"method","createDestroyBehavior":"method","createStartBehavior":"method","createMergeComment":"method","createBehaviorHeader":"method","createBehaviorParameters":"method","createBehaviorParametersEvent":"method","createBehaviorParametersEventArray":"method"},"v1f156196ff13c17":{"_name":"Log","type":"property","log":"property","_id":"v1f156196ff13c17","_inherit":["_Component"]},"p1f6f51d9f111925":{"_name":"MenuAction","html":"link","position":"property","type":"property","hide":"method","show":"method","render":"method","click":"event","_id":"p1f6f51d9f111925","_inherit":["_Component"]},"a1097d1ea0812005":{"_name":"MenuBar","logo":"property","header":"property","items":"collection","actions":"collection","render":"method","clear":"method","_id":"a1097d1ea0812005","_inherit":["_Component"]},"t14a79156a81862a":{"_name":"MenuHeader","html":"link","type":"property","hide":"method","show":"method","render":"method","_id":"t14a79156a81862a","_inherit":["_Component"]},"l1d113198721599d":{"_name":"MenuItem","html":"link","position":"property","type":"property","name":"property","platform":"property","render":"method","click":"event","_id":"l1d113198721599d","_inherit":["_Component"]},"h1d5181d0f31d7fc":{"_name":"MenuLogo","html":"link","hide":"method","show":"method","render":"method","_id":"h1d5181d0f31d7fc","_inherit":["_Component"]},"t198c41630f1d37e":{"_name":"Message","success":"method","info":"method","warning":"method","danger":"method","clean":"method","_id":"t198c41630f1d37e","_inherit":["_Component"]},"f199ca1d9b01cdcf":{"_name":"ModelBehavior","uuid":"property","title":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"f199ca1d9b01cdcf","_inherit":["_Component"]},"o1d37f1e7c511205":{"_name":"ModelClass","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"o1d37f1e7c511205","_inherit":["_Component"]},"s10e57101f91fe18":{"_name":"ModelComponent","title":"property","uuid":"property","model":"property","document":"property","content":"property","render":"method","hide":"method","show":"method","_id":"s10e57101f91fe18","_inherit":["_Component"]},"l15c261708e1fa7f":{"_name":"ModelLog","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"l15c261708e1fa7f","_inherit":["_Component"]},"b19a2a1904c1521c":{"_name":"ModelSchema","title":"property","uuid":"property","content":"property","document":"property","editable":"property","render":"method","hide":"method","show":"method","_id":"b19a2a1904c1521c","_inherit":["_Component"]},"v12a9113d7e19b21":{"_name":"ModelSystem","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"v12a9113d7e19b21","_inherit":["_Component"]},"h162301b2eb1e8f8":{"_name":"ModelType","title":"property","uuid":"property","content":"property","document":"property","render":"method","hide":"method","show":"method","_id":"h162301b2eb1e8f8","_inherit":["_Component"]},"z1e592183e81ce64":{"_id":"z1e592183e81ce64","_name":"Router","_inherit":["_Component"],"start":"method","update":"method"},"p14e93127f6159df":{"_name":"SpaceItem","name":"property","uuid":"property","click":"event","_id":"p14e93127f6159df","_inherit":["_Component"]},"v194541e0431ce95":{"_name":"Spaces","items":"collection","systems":"collection","components":"collection","render":"method","clear":"method","_id":"v194541e0431ce95","_inherit":["_Component"],"designer":"property"},"y1efb3178341398a":{"_name":"State","_inherit":["_Component"],"type":"property","component":"property","lastPage":"property","messages":"property","menu":"property","previousMenu":"property","space":"property","navigation":"property","logs":"collection","_id":"y1efb3178341398a"},"b1d38a143001d960":{"_name":"Store","uuid":"property","collection":"property","data":"property","extra":"property","_id":"b1d38a143001d960","_inherit":["_Component"]},"u1aff21b1e617f34":{"_name":"System","name":"property","master":"property","version":"property","description":"property","schemas":"property","models":"property","behaviors":"property","types":"property","components":"property","_id":"u1aff21b1e617f34","_inherit":["_Component"]},"l1ea0910f981a5f3":{"_id":"l1ea0910f981a5f3","_name":"SystemFactory","_inherit":["_Component"],"system":"property","syncModel":"method","syncBehavior":"method","syncComponent":"method","createModel":"method","createBehavior":"method","deleteSchema":"method","generateId":"method","getGeneratedSchema":"method","getGeneratedModel":"method","getParents":"method","mergeBehavior":"method","mergeSystem":"method","updateBehavior":"method","updateComponent":"method","updateComponentId":"method","deleteComponent":"method","createComponent":"method","updateSystem":"method","overwriteComponent":"method","deleteBehavior":"method","udpdateBehavior":"method","updateModelId":"method","updateModel":"method","updateSchemaId":"method","updateSchema":"method","updateSchemaName":"method","deleteType":"method","updateType":"method","create":"method","toJSON":"method","addSchema":"method","addType":"method","addComponent":"method","addBehavior":"method","getModelPaths":"method","isModel":"method","isType":"method","getModelPathType":"method"},"f1257f17deb16097":{"_name":"ToolBar","items":"collection","render":"method","_id":"f1257f17deb16097","_inherit":["_Component"]},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"f1092816b571e03c":{"_name":"Workspace","create":"method","load":"method","clear":"method","render":"method","_id":"f1092816b571e03c","_inherit":["_Component"]},"f1a0b01c1fb15a8e":{"_id":"f1a0b01c1fb15a8e","_name":"MessageHelp","_inherit":["_Component"],"render":"method","remove":"method"},"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"_Storage","_inherit":["_Component"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","$editorUpdateSchemaName":{"params":[{"name":"name","type":"string"},{"name":"id","type":"string"}]},"$designerSync":{},"$appLoadSystem":{"params":[{"name":"system","type":"object"}]},"$designerCreateBehavior":{"params":[{"name":"behavior","type":"object"}]},"$editorUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$designerUpdateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"$editorDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerDeleteBehavior":{"params":[{"name":"id","type":"string"}]},"$designerCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorUpdateComponentId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"},{"name":"collection","type":"string"}]},"$designerUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$editorDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$designerCreateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorUpdateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"$editorDeleteType":{"params":[{"name":"id","type":"string"}]},"$designerCreateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"$editorUpdateSchemaId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteSchema":{"params":[{"name":"id","type":"string"}]},"$designerCreateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$designerUpdateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"$editorUpdateModelId":{"params":[{"name":"oldId","type":"string"},{"name":"newId","type":"string"}]},"$designerDeleteModel":{"params":[{"name":"id","type":"string"}]},"$designerDeleteType":{"params":[{"name":"id","type":"string"}]},"$editorUpdateSystem":{"params":[{"name":"id","type":"string"},{"name":"system","type":"object"}]},"$appLogDebug":{"params":[{"name":"message","type":"string"}]},"$appLogInfo":{"params":[{"name":"message","type":"string"}]},"$appLogWarn":{"params":[{"name":"message","type":"string"}]},"$appLogError":{"params":[{"name":"message","type":"string"}]},"send":{"params":[{"name":"message","type":"message"}]},"$runtimeCreateComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"$runtimeDeleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"$runtimeUpdateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"field","type":"string"},{"name":"value","type":"any"}]},"$designerSetSystem":{"params":[{"name":"system","type":"object","mandatory":false,"default":{}}]}},"j1933417dac11240":{"_name":"CSS","source":{"type":"css","readOnly":true,"mandatory":true,"default":""},"_id":"j1933417dac11240"},"q129be1c61b18285":{"_name":"Designer","version":{"type":"string","readOnly":false,"mandatory":false,"default":"3.5.3"},"runWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"debugWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null},"linkModel":{"params":[{"name":"source","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""}]},"save":{},"saveCordova":{},"welcome":{},"render":{},"open":{"params":[{"name":"url","type":"string","mandatory":false,"default":""},{"name":"target","type":"string","mandatory":false,"default":""},{"name":"isExt","type":"boolean","mandatory":false,"default":false}]},"saveAs":{"params":[{"name":"data","type":"object","mandatory":false,"default":{}},{"name":"fileName","type":"string","mandatory":false,"default":""}]},"isCordova":{"result":"boolean"},"isElectron":{"result":"boolean"},"runMessages":{"params":[{"name":"messages","type":"array","mandatory":true,"default":[]}]},"updateCordovaContext":{},"_id":"q129be1c61b18285","installExtensions":{},"isMac":{"result":"boolean"},"addShorcuts":{},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]}},"b169321637f19101":{"_id":"b169321637f19101","_name":"Diagram","_description":"","ref":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""},"zoom":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":1},"render":{"description":"","params":[],"result":"any"},"data":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"l1d4181e4d71ade2":{"_name":"Dialog","title":{"type":"text","readOnly":true,"mandatory":true,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"data":{"type":"any","readOnly":false,"mandatory":false,"default":{}},"show":{},"hide":{},"cancel":{},"ok":{},"_id":"l1d4181e4d71ade2","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""}},"n14a831448a1ef6a":{"_name":"DialogCopyright","_id":"n14a831448a1ef6a"},"g1ab8111f2d1c7ce":{"_name":"DialogBehaviorCreation","_id":"g1ab8111f2d1c7ce"},"t12b5d1be8512beb":{"_name":"DialogComponentCreation","_id":"t12b5d1be8512beb"},"t15a691554c1155f":{"_name":"DialogConfig","_id":"t15a691554c1155f"},"c1b56e1fdb3174a8":{"_name":"DialogDropFile","_id":"c1b56e1fdb3174a8"},"h1fedc1441312ac4":{"_name":"DialogExport","_id":"h1fedc1441312ac4"},"t1c8ab1e8c010544":{"_name":"DialogImport","_id":"t1c8ab1e8c010544"},"w15777160d41bb38":{"_name":"DialogImportFile","mergeSystem":{},"importSystem":{},"_id":"w15777160d41bb38"},"v108dd1f00315ebe":{"_name":"DialogModelCreation","_id":"v108dd1f00315ebe"},"o19888142191439e":{"_name":"DialogComponentInfo","_id":"o19888142191439e"},"i15fee18f0e164ba":{"_name":"DialogSchemaCreation","_id":"i15fee18f0e164ba"},"u1caa614eb713967":{"_name":"DialogSearch","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"u1caa614eb713967","currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"e167bf16b5c1fd5f":{"_name":"DialogShare","_id":"e167bf16b5c1fd5f"},"k105d3130531ae5c":{"_name":"DialogSync","_id":"k105d3130531ae5c"},"k19f8d10dec1beda":{"_name":"DialogSystemCreation","_id":"k19f8d10dec1beda"},"x1e7931468415710":{"_name":"DialogTypeCreation","_id":"x1e7931468415710"},"e1dd3f1e688107a8":{"_name":"DialogWelcome","_id":"e1dd3f1e688107a8"},"u147e01d928148d4":{"_id":"u147e01d928148d4","_name":"DialogExtension","add":{},"remove":{}},"p17fe617ee3189f7":{"_id":"p17fe617ee3189f7","_name":"DialogCommand","filter":{"type":"string","readOnly":false,"mandatory":false,"default":""},"currentSelection":{"type":"number","readOnly":false,"mandatory":false,"default":-1},"nbResult":{"type":"number","readOnly":false,"mandatory":false,"default":0}},"i1d79c1b51e1c166":{"_id":"i1d79c1b51e1c166","_name":"DialogDelete"},"y11f3c1fe9b1f239":{"_id":"y11f3c1fe9b1f239","_name":"DialogDropDiagram","_description":""},"d4ae5298-d26e-4fc5-8919-aa250edea85c":{"_id":"d4ae5298-d26e-4fc5-8919-aa250edea85c","_name":"DialogInstallPWA","_description":"","deferredPrompt":{"description":"","type":"any","readOnly":false,"mandatory":false,"default":""}},"17a551ea931289c":{"_id":"17a551ea931289c","_name":"Editor","editor":{"type":"editorRef","readOnly":true,"mandatory":true,"default":{}},"render":{},"getValue":{"result":"any"},"setValue":{"params":[{"name":"val","type":"any","mandatory":false,"default":""}]},"type":{"type":"editorRuntimeType","readOnly":false,"mandatory":false,"default":"ace"},"setEditor":{"params":[{"name":"mode","type":"string","mandatory":false,"default":""},{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1},{"name":"autocomplete","type":"boolean","mandatory":false,"default":false}]},"context":{"type":"editorType","readOnly":false,"mandatory":false,"default":"system"},"initValue":{"params":[{"name":"value","type":"string","mandatory":false,"default":""},{"name":"lineNumber","type":"number","mandatory":false,"default":1}]},"undo":{},"redo":{},"selectAll":{},"copy":{},"paste":{}},"v1ca291072418fa4":{"_id":"v1ca291072418fa4","_name":"Export","toJSON":{"params":[{"name":"isMaster","type":"boolean","mandatory":false,"default":true}],"result":"string"},"toHTML":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toNode":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toJavaScript":{"params":[{"name":"logLevel","type":"string","mandatory":false,"default":"info"}],"result":"string"},"toGraphviz":{"description":"","params":[{"name":"diagramType","description":"","type":"string","mandatory":false,"default":"class"}],"result":"string"}},"h19261129ee12d64":{"_id":"h19261129ee12d64","_name":"Extension","source":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"installed":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"isCore":{"type":"boolean","readOnly":false,"mandatory":false,"default":true}},"1c23c1ed49186e9":{"_id":"1c23c1ed49186e9","_name":"Github","refresh":{},"push":{"params":[{"name":"comment","type":"string","mandatory":false,"default":""},{"name":"createHTML","type":"boolean","mandatory":false,"default":false},{"name":"createNode","type":"boolean","mandatory":false,"default":false},{"name":"logLevel","type":"string","mandatory":false,"default":"debug"},{"name":"createPackage","type":"boolean","mandatory":false,"default":false}]},"merge":{"params":[{"name":"sys","type":"object","mandatory":true,"default":{}}]}},"w1417e1d6d613a0d":{"_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"_id":"w1417e1d6d613a0d","render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]},"getHTML":{"description":"","params":[],"result":"string"}},"eabc29ab-77ba-4eee-ad98-68dac6797ee8":{"_id":"eabc29ab-77ba-4eee-ad98-68dac6797ee8","_name":"Strings","_description":"","help_systems":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_schemas":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_models":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_types":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_behaviors":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_components":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"help_logs":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}},"ba12d3ed-d8cc-4809-9821-9a1351268fc5":{"_id":"ba12d3ed-d8cc-4809-9821-9a1351268fc5","_name":"Internationalization","_description":"","get":{"description":"","params":[{"description":"","name":"key","type":"string","mandatory":true,"default":""}],"result":"string"},"locale":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":"en-US"}},"o180bb1fb96134b7":{"_name":"JS","source":{"type":"javascript","readOnly":true,"mandatory":true,"default":""},"_id":"o180bb1fb96134b7"},"v1146f14eaa15324":{"_name":"JSON","source":{"type":"json","readOnly":true,"mandatory":true,"default":{}},"_id":"v1146f14eaa15324","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"i1bab91d926104d3":{"_id":"i1bab91d926104d3","_name":"Language","target":{"type":"language","readOnly":false,"mandatory":false,"default":"javascript"},"createBehaviorBody":{"params":[{"name":"returnedType","type":"string","mandatory":false,"default":"string"}],"result":"string"},"createBehavior":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""},{"name":"body","type":"string","mandatory":false,"default":""}],"result":"string"},"createDestroyBehavior":{"result":"string"},"createStartBehavior":{"result":"string"},"createMergeComment":{"params":[{"name":"systemName","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorHeader":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"params","type":"string","mandatory":false,"default":""}],"result":"string"},"createBehaviorParameters":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}],"result":"string"},"createBehaviorParametersEvent":{"result":"string"},"createBehaviorParametersEventArray":{"result":"string"}},"l100ba180b514a8b":{"_name":"Log","type":{"type":"string","readOnly":true,"mandatory":true,"default":"debug"},"log":{"type":"string","readOnly":true,"mandatory":true,"default":""},"_id":"l100ba180b514a8b"},"w124ac16b591df57":{"_name":"MenuAction","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"w124ac16b591df57","click":{"description":"","params":[]}},"y18b1217aaa13456":{"_name":"MenuBar","logo":{"type":"MenuLogo","readOnly":false,"mandatory":false,"default":""},"header":{"type":"MenuHeader","readOnly":false,"mandatory":false,"default":""},"items":{"type":["MenuItem"],"readOnly":false,"mandatory":false,"default":[]},"actions":{"type":["MenuAction"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"y18b1217aaa13456"},"f13ebe1ad331b263":{"_name":"MenuHeader","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"hide":{},"show":{},"render":{},"_id":"f13ebe1ad331b263"},"u1f9a01abe31b3bf":{"_name":"MenuItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f9a01abe31b3bf","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"p19358155261f3b0":{"_name":"MenuLogo","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"p19358155261f3b0"},"i17fe71fd15150c9":{"_name":"Message","success":{"params":[{"name":"message","type":"string"}]},"info":{"params":[{"name":"message","type":"string"}]},"warning":{"params":[{"name":"message","type":"string"}]},"danger":{"params":[{"name":"message","type":"string"}]},"clean":{},"_id":"i17fe71fd15150c9"},"l19cd5176761a073":{"_name":"ModelBehavior","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l19cd5176761a073"},"d19365156f61a519":{"_name":"ModelClass","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"d19365156f61a519"},"a14b6c1b21b13626":{"_name":"ModelComponent","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"model":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"hide":{},"show":{},"render":{},"_id":"a14b6c1b21b13626"},"n1d0441c3c817fc9":{"_name":"ModelLog","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"n1d0441c3c817fc9"},"e1081c193ea1fd07":{"_name":"ModelSchema","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"editable":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"hide":{},"show":{},"render":{},"_id":"e1081c193ea1fd07"},"x1444a1ac6c10ce6":{"_name":"ModelSystem","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"x1444a1ac6c10ce6"},"l1c1a91b69b1dc5b":{"_name":"ModelType","title":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"content":{"type":"string","readOnly":false,"mandatory":false,"default":""},"document":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"hide":{},"show":{},"render":{},"_id":"l1c1a91b69b1dc5b"},"c1b00612faf188cf":{"_id":"c1b00612faf188cf","_name":"Router","start":{},"update":{}},"p1d9251b9e619c48":{"_name":"SpaceItem","name":{"type":"string","readOnly":false,"mandatory":false,"default":""},"uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"click":{},"_id":"p1d9251b9e619c48"},"i15f6718c9d19b10":{"_name":"Spaces","items":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"systems":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"components":{"type":["SpaceItem"],"readOnly":false,"mandatory":false,"default":[]},"clear":{},"render":{},"_id":"i15f6718c9d19b10","designer":{"type":"Designer","readOnly":true,"mandatory":false,"default":{}}},"j18ad71fd8c1c175":{"_name":"State","type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"_id":"j18ad71fd8c1c175","lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}},"u1692f1399a13209":{"_name":"Store","uuid":{"type":"string","readOnly":false,"mandatory":false,"default":""},"collection":{"type":"string","readOnly":false,"mandatory":false,"default":""},"data":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"extra":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"_id":"u1692f1399a13209"},"t1fcf714b4c15616":{"_name":"System","name":{"type":"string","readOnly":false,"mandatory":false,"default":"system"},"master":{"type":"boolean","readOnly":false,"mandatory":false,"default":false},"version":{"type":"string","readOnly":false,"mandatory":false,"default":"0.0.1"},"description":{"type":"string","readOnly":false,"mandatory":false,"default":""},"schemas":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"models":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"behaviors":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"types":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"components":{"type":"json","readOnly":false,"mandatory":false,"default":{}},"_id":"t1fcf714b4c15616"},"h1ac4f1c0511caa0":{"_id":"h1ac4f1c0511caa0","_name":"SystemFactory","system":{"type":"System","readOnly":false,"mandatory":false,"default":""},"syncModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}]},"syncBehavior":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}}]},"syncComponent":{"params":[{"name":"model","type":"object","mandatory":false,"default":{}},{"name":"oldModel","type":"object","mandatory":false,"default":{}},{"name":"forceDelete","type":"boolean","mandatory":false,"default":true}]},"createModel":{"params":[{"name":"schema","type":"object","mandatory":false,"default":{}}],"result":"object"},"createBehavior":{"params":[{"name":"type","type":"string","mandatory":false,"default":"method"},{"name":"model","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""},{"name":"def","type":"object","mandatory":false,"default":{}}]},"deleteSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"sync","type":"boolean","mandatory":false,"default":true}]},"generateId":{"result":"string"},"getGeneratedSchema":{"params":[{"name":"schema","type":"string","mandatory":true,"default":""}],"result":"object"},"getGeneratedModel":{"params":[{"name":"model","type":"string","mandatory":true,"default":""}],"result":"object"},"mergeBehavior":{"params":[{"name":"behaviors","type":"object","mandatory":true,"default":{}},{"name":"behavior","type":"object","mandatory":true,"default":{}},{"name":"sysId","type":"string","mandatory":true,"default":""},{"name":"systemName","type":"string","mandatory":true,"default":""}]},"mergeSystem":{"params":[{"name":"sys","type":"any","mandatory":false,"default":null}]},"updateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"field","type":"string","mandatory":false,"default":""},{"name":"value","type":"any","mandatory":false,"default":""}]},"deleteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""}]},"createComponent":{"params":[{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"updateSystem":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"system","type":"object","mandatory":false,"default":{}}]},"overwriteComponent":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string","mandatory":false,"default":""},{"name":"component","type":"object","mandatory":false,"default":{}}]},"deleteBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"udpdateBehavior":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"behavior","type":"object","mandatory":false,"default":{}}]},"updateModelId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateModel":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"model","type":"object","mandatory":false,"default":{}}]},"updateSchemaId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""}]},"updateSchema":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"schema","type":"object","mandatory":false,"default":{}}]},"updateSchemaName":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"id","type":"string","mandatory":false,"default":""}]},"deleteType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""}]},"updateType":{"params":[{"name":"id","type":"string","mandatory":false,"default":""},{"name":"type","type":"object","mandatory":false,"default":{}}]},"create":{"params":[{"name":"sys","type":"object","mandatory":false,"default":{}},{"name":"withStartMethod","type":"boolean","mandatory":false,"default":false}],"result":"System"},"toJSON":{"result":"any"},"addSchema":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"object"},"addType":{"params":[{"name":"name","type":"string","mandatory":false,"default":""},{"name":"isEnum","type":"boolean","mandatory":false,"default":false}],"result":"object"},"addComponent":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"object"},"addBehavior":{"params":[{"name":"model","type":"string","mandatory":false,"default":""},{"name":"component","type":"string","mandatory":false,"default":""},{"name":"state","type":"string","mandatory":false,"default":""}],"result":"object"},"updateComponentId":{"params":[{"name":"oldId","type":"string","mandatory":false,"default":""},{"name":"newId","type":"string","mandatory":false,"default":""},{"name":"collection","type":"string"}]},"getModelPaths":{"params":[{"name":"model","type":"string","mandatory":false,"default":""}],"result":"array"},"isModel":{"params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getModelPathType":{"description":"","params":[{"description":"","name":"model","type":"string","mandatory":false,"default":""},{"name":"path","description":"","type":"string","mandatory":false,"default":""}],"result":"any"},"isType":{"description":"","params":[{"name":"name","type":"string","mandatory":false,"default":""}],"result":"boolean"},"getParents":{"description":"","params":[{"description":"","name":"name","type":"string","mandatory":false,"default":""}],"result":"array"}},"l129a713e681c903":{"_name":"ToolBar","items":{"type":["ToolBarItem"],"readOnly":false,"mandatory":false,"default":[]},"render":{},"_id":"l129a713e681c903"},"u1f4c7177bb1a459":{"_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":""},"position":{"type":"number","readOnly":false,"mandatory":false,"default":0},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"_id":"u1f4c7177bb1a459","platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"v1435e1809e10be7":{"_name":"Workspace","create":{},"load":{},"clear":{},"_id":"v1435e1809e10be7","render":{}},"k1127212a8e18f9c":{"_id":"k1127212a8e18f9c","_name":"MessageHelp","render":{},"remove":{}},"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"_Storage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"obj","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}},"j1311d115381b738":{"_id":"j1311d115381b738","_name":"State","type":{"type":"string","readOnly":false,"mandatory":false,"default":""},"component":{"type":"string","readOnly":false,"mandatory":false,"default":""},"lastPage":{"type":"string","readOnly":false,"mandatory":false,"default":"index.html"},"messages":{"type":"array","readOnly":false,"mandatory":false,"default":[]},"menu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"previousMenu":{"type":"string","readOnly":false,"mandatory":false,"default":""},"space":{"type":"string","readOnly":false,"mandatory":false,"default":""},"logs":{"type":["Log"],"readOnly":false,"mandatory":false,"default":[]},"navigation":{"type":"navigation","readOnly":false,"mandatory":false,"default":{"menu":[],"spaces":[]}}}},"behaviors":{"p13d9f1c84d121d2":{"_id":"p13d9f1c84d121d2","component":"Designer","state":"isCordova","action":"function isCordova() {\n var result = false;\n \n if (typeof cordova !== 'undefined') {\n result = true;\n }\n return result;\n}"},"p12f03101af19689":{"_id":"p12f03101af19689","component":"Designer","state":"isElectron","action":"function isElectron() {\n var result = false;\n \n if (typeof document !== 'undefined' && typeof global !== 'undefined') {\n result = true;\n }\n return result;\n}"},"s1472210b2419449":{"_id":"s1472210b2419449","component":"Designer","state":"open","action":"function open(url, target, isExt) {\n var ref = null,\n that = this;\n \n function _getRelativePath() {\n var result = 'index.html';\n \n switch (that.require('state').menu()) {\n case 'systems':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#systems#' + that.require('factory').system().name();\n }\n break;\n case 'schemas':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#schemas';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'models':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#models';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'types':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#types';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'behaviors':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#behaviors';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'components':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#components';\n if (that.require('state').space()) {\n result = result + '#' + that.require('state').space();\n }\n }\n break;\n case 'logs':\n if (that.require('factory').system()) {\n result = result + '#' + that.require('factory').system().id() + '#logs';\n }\n break;\n default:\n break;\n }\n \n return result;\n }\n \n switch(true) {\n case this.isElectron():\n if (isExt) {\n ref = require('electron').shell.openExternal(url, target); \n } else {\n if (target === '_self') {\n window.location.href = url;\n } else {\n ref = window.open(url, target);\n ref.focus();\n }\n }\n break;\n case this.isCordova():\n if (isExt) {\n window.open(url, '_system');\n } else { \n if (url.indexOf('index.html') === -1 || url.indexOf('app/') !== -1) {\n /*\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n \n url = url + '?system=' + encodeURIComponent(JSON.stringify(system));\n url = url + '&ref=' + encodeURIComponent(_getRelativePath());\n */\n url = url + '?ref=' + encodeURIComponent(_getRelativePath());\n }\n document.location.href = url;\n }\n break;\n default:\n ref = window.open(url, target);\n break;\n }\n \n return ref;\n}"},"g1043310ce91f287":{"_id":"g1043310ce91f287","component":"Designer","state":"saveAs","action":"function saveAs(data, fileName) {\n var textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null,\n message = this.require('message');\n \n textToWrite = JSON.stringify(data);\n fileNameToSaveAs = fileName;\n \n if (!this.isElectron()) {\n \n textFileAsBlob = new Blob([textToWrite], {\n type: 'text/plain'\n });\n \n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n downloadLink.download = fileNameToSaveAs;\n downloadLink.innerHTML = 'Download File';\n if (window.URL != null) {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n } else {\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n downloadLink.onclick = function (event) {\n document.body.removeChild(event.target);\n };\n downloadLink.style.display = 'none';\n document.body.appendChild(downloadLink);\n }\n \n downloadLink.click();\n }\n \n message.success('Exportation is done.');\n } else {\n var {dialog} = require(\"electron\").remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function(err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n}"},"u16f78106f713bd5":{"_id":"u16f78106f713bd5","component":"Designer","state":"updateCordovaContext","action":"function updateCordovaContext() {\n var params = {},\n urlParams = [],\n system = null;\n \n urlParams = document.location.href.split('?');\n\n if (urlParams.length > 1) {\n urlParams = urlParams[1].split('&');\n urlParams.forEach(function (urlParam) {\n var name = '',\n value = '';\n\n name = urlParam.split('=')[0].trim();\n value = urlParam.split('=')[1].trim();\n\n params[name] = decodeURIComponent(value);\n }); \n }\n \n \n //if (params.system) {\n //system = JSON.parse(params.system);\n //this.require('storage').set(system._id, system);\n //}\n \n if (params.ref) {\n this.require('state').lastPage(params.ref);\n }\n}"},"i1ae8c1cb711320e":{"_id":"i1ae8c1cb711320e","component":"Designer","state":"installExtensions","action":"function installExtensions() { \n\tvar extensions = null,\n\t numExtension = -1;\n \n // extensions\n extensions = this.require('storage').get('system-designer-extensions');\n if (extensions && extensions.extensions && extensions.extensions.length) {\n extensions.extensions.forEach(function (extension) {\n var Extension = this.require('Extension'),\n system = {},\n cleanJson = {},\n reg = null,\n needsUpdate = false;\n \n numExtension++; \n \n if (extension.installed) { \n system = extension.source;\n \n try {\n // check if we have to update the extension\n if (this.require(extension._id) && this.require(extension._id).source().version > system.version) {\n system = this.require(extension._id).source();\n needsUpdate = true;\n }\n \n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id );\n system = JSON.parse(cleanJson);\n \n this.require('runtime').install(system);\n \n new Extension(extension);\n \n if (needsUpdate) {\n // save the updated system\n extensions.extensions[numExtension].source = system;\n this.require('storage').set('system-designer-extensions', extensions);\n \n this.require('message').success('Extension \\'' + system.description + '\\' has been updated.');\n }\n } catch (e) {\n this.require('message').danger('Can not install an extension: ' + e.message);\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j1fc6515c8f1838f":{"_id":"j1fc6515c8f1838f","component":"Designer","state":"isMac","action":"function isMac() { \n\tvar result = false;\n\t\n\tif (navigator.userAgent.toLowerCase().indexOf('macintosh') !== -1) {\n\t result = true;\n\t} \n\treturn result;\n}","useCoreAPI":false,"core":false},"k10e3f115ef1a83b":{"_id":"k10e3f115ef1a83b","component":"DialogCopyright","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-copyright.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-copyright-modal-ok');\n dom.addEventListener('click', function (event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-copyright-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"k191d71c949120ec":{"_id":"k191d71c949120ec","component":"DialogCopyright","state":"show","action":"function show() { \n $('#designer-dialog-copyright-modal').modal('show');\n}","useCoreAPI":false,"core":false},"z17fdc13a9a1f940":{"_id":"z17fdc13a9a1f940","component":"DialogCopyright","state":"hide","action":"function hide() { \n $('#designer-dialog-copyright-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"k11cb01de7316017":{"_id":"k11cb01de7316017","component":"DialogImport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-import.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n \n // events\n dom = document.getElementById('designer-dialog-import-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-import-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ff331a4a41052e":{"_id":"n1ff331a4a41052e","component":"DialogImport","state":"show","action":"function show() { \n $('#designer-dialog-import-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"c10f7913c3113bb1":{"_id":"c10f7913c3113bb1","component":"DialogImport","state":"hide","action":"function hide() { \n $('#designer-dialog-import-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w17f82152171991e":{"_id":"w17f82152171991e","component":"DialogWelcome","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n \n $('#designer-dialog').empty();\n \n html = this.require('dialog-modal-welcome.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n \n // events\n dom = document.getElementById('designer-dialog-welcome-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l149ed1bf1411137":{"_id":"l149ed1bf1411137","component":"DialogWelcome","state":"show","action":"function show() { \n $('#designer-dialog-welcome-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"g184031e6b71648a":{"_id":"g184031e6b71648a","component":"DialogWelcome","state":"hide","action":"function hide() { \n $('#designer-dialog-welcome-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z1d0ec1a0ce18278":{"_id":"z1d0ec1a0ce18278","component":"DialogSync","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-sync.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-sync-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-hasHTML');\n dom.addEventListener('click', function click(event) {\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n } else {\n $('#designer-dialog-sync-options-log-level').hide();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-commit');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').show();\n $('#designer-dialog-sync-options-area').show();\n $('#designer-dialog-sync-options-node').show();\n if ($('#designer-dialog-type-creation-hasHTML')[0].checked) {\n $('#designer-dialog-sync-options-log-level').show();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-sync-refresh');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-sync-comments-area').hide();\n $('#designer-dialog-sync-options-area').hide();\n $('#designer-dialog-sync-options-log-level').hide();\n $('#designer-dialog-sync-options-node').hide();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-sync-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n \n}","useCoreAPI":false,"core":false},"f1df481fac01acdc":{"_id":"f1df481fac01acdc","component":"DialogSync","state":"show","action":"function show() { \n $('#designer-dialog-sync-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"m187b818e2f1b30f":{"_id":"m187b818e2f1b30f","component":"DialogSync","state":"hide","action":"function hide() { \n $('#designer-dialog-sync-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"y1934b1e72412bd0":{"_id":"y1934b1e72412bd0","component":"DialogShare","state":"init","action":"function init(conf) { \n var html = null,\n dom = null,\n sys = '';\n\n $('#designer-dialog').empty();\n\n sys = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n html = this.require('dialog-modal-share.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, window.location.toString().split('#')[0] + '?system=' + encodeURIComponent(JSON.stringify(sys)))\n );\n\n // events\n dom = document.getElementById('designer-dialog-share-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-share-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"l1eb0516ca015910":{"_id":"l1eb0516ca015910","component":"DialogShare","state":"show","action":"function show() { \n $('#designer-dialog-share-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"q1e62a1c9d61ba89":{"_id":"q1e62a1c9d61ba89","component":"DialogShare","state":"hide","action":"function hide() { \n $('#designer-dialog-share-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"s1d027166051b0ad":{"_id":"s1d027166051b0ad","component":"DialogConfig","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n storeConfig = null,\n designer = that.require('designer');\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-config.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default config value\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.debugType === 'undefined') {\n storeConfig.debugType = 'client';\n this.require('storage').set('system-designer-config', storeConfig);\n }\n if (storeConfig.debugType === 'client') {\n $('#designer-dialog-config-radio-client').attr('checked', true);\n $('#designer-dialog-config-server-form').hide();\n } else {\n $('#designer-dialog-config-radio-server').attr('checked', true);\n $('#designer-dialog-config-client-form').hide();\n }\n if (storeConfig.urlClient) {\n $('#designer-dialog-config-url-client')[0].value = storeConfig.urlClient;\n }\n if (storeConfig.urlServer) {\n $('#designer-dialog-config-url-server')[0].value = storeConfig.urlServer;\n }\n if (storeConfig.githubToken) {\n $('#designer-dialog-config-github-token')[0].value = atob(storeConfig.githubToken);\n }\n if (storeConfig.githubRepository) {\n $('#designer-dialog-config-github-repository')[0].value = storeConfig.githubRepository;\n }\n if (storeConfig.advancedMode) {\n $('#designer-dialog-config-advanced-mode-isAdvanced').attr('checked', true);\n }\n if (storeConfig.language) {\n $('#designer-dialog-config-language-select').val(storeConfig.language);\n }\n \n // events\n dom = document.getElementById('designer-dialog-config-radio-client');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'client';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').show();\n $('#designer-dialog-config-server-form').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-radio-server');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.debugType = 'server';\n this.require('storage').set('system-designer-config', config);\n\n $('#designer-dialog-config-client-form').hide();\n $('#designer-dialog-config-server-form').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-client');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-client').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-token');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-token').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-github-repository');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-github-repository').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-url-server');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-config-url-server').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-advanced-mode-isAdvanced');\n dom.addEventListener('click', function click(event) {\n var config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n\n config.advancedMode = $('#designer-dialog-config-advanced-mode-isAdvanced').prop('checked');\n this.require('storage').set('system-designer-config', config);\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-config-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-config-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"f16d5719c171dfe5":{"_id":"f16d5719c171dfe5","component":"DialogConfig","state":"show","action":"function show() { \n $('#designer-dialog-config-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"l1cb42113d7185c8":{"_id":"l1cb42113d7185c8","component":"DialogConfig","state":"hide","action":"function hide() { \n $('#designer-dialog-config-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"f1f43d11c0d15597":{"_id":"f1f43d11c0d15597","component":"DialogConfig","state":"ok","action":"function ok() { \n var config = this.require('storage').get('system-designer-config');\n var previousLanguage = '';\n\n if (!config) {\n config = {};\n }\n\n config.urlClient = $('#designer-dialog-config-url-client')[0].value;\n config.urlServer = $('#designer-dialog-config-url-server')[0].value;\n config.githubToken = btoa($('#designer-dialog-config-github-token')[0].value);\n config.githubRepository = $('#designer-dialog-config-github-repository')[0].value;\n \n // refresh if current language has changed\n previousLanguage = config.language;\n config.language = $('#designer-dialog-config-language-select').val();\n if (previousLanguage !== config.language) {\n window.location.reload();\n }\n\n this.require('storage').set('system-designer-config', config);\t\n}","useCoreAPI":false,"core":false},"t143b71071c16185":{"_id":"t143b71071c16185","component":"DialogImportFile","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n that = this,\n libraries = [],\n library = '',\n systems = [],\n system = '',\n sys = '',\n systemIds = '',\n length = 0,\n i = 0,\n list = '',\n platform = '',\n platformLibraries = [],\n systemClean = '';\n\n $('#designer-dialog').empty();\n\n libraries = this.require('db').collections().JSON.find({\n 'platform': 'all'\n });\n \n // get platformspecific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformLibraries = this.require('db').collections().JSON.find({\n 'platform': platform\n });\n \n libraries = libraries.concat(platformLibraries);\n \n // sort JSON\n libraries.sort(function (itemA, itemB) {\n if (itemA._id > itemB._id) {\n return 1;\n }\n if (itemA._id < itemB._id) {\n return -1;\n }\n return 0;\n });\n \n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n\n list = list + '' +\n '

    ' + library.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + library.source().version + '

    ' +\n '
    ';\n }\n\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n sys = sys + '' +\n '

    ' + system.name + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n\n html = this.require('dialog-modal-import-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{library}}/gi, list)\n .replace(/{{systems}}/gi, sys)\n );\n\n // init\n if (sys === '') {\n $('#designer-dialog-import-modal-from-systems-input').hide();\n }\n if (!this.require('factory').system()) {\n $('#designer-dialog-import-file-modal-merge').hide();\n }\n\n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n systems = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-systems-', '');\n \n that.data(that.require('storage').get(id));\n\n // remove old active\n systems = document.getElementById('designer-dialog-import-file-modal-systems');\n\n length = systems.children.length;\n for (i = 0; i < length; i++) {\n $(systems.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = systemIds.length;\n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systems.systems[i]);\n if (this.require('factory').system() && this.require('factory').system().id() === system._id) {\n } else {\n dom = document.getElementById('designer-dialog-import-file-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n\n // library events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0,\n system = {};\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-import-file-modal-library-', '');\n\n // case of extensions\n system = that.require(id).source();\n if (system.name.indexOf('extension-') !== -1) {\n system.name = 'extension-' + Math.floor((1 + Math.random()) * 0x10000).toString(16);\n system._id = that.require('factory').generateId();\n \n // to avoid an issue when removing extensions\n systemClean = JSON.stringify(system);\n \n systemClean = systemClean.replace(/d1bdde1f59f1befe/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/n1467b1097a16481/g, that.require('factory').generateId());\n systemClean = systemClean.replace(/t1fb0b150c810528/g, that.require('factory').generateId());\n\n system = JSON.parse(systemClean);\n }\n \n that.data(system);\n\n // remove old active\n libraries = document.getElementById('designer-dialog-import-file-modal-library');\n\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n length = libraries.length;\n for (i = 0; i < length; i++) {\n library = this.require(libraries[i]._id);\n dom = document.getElementById('designer-dialog-import-file-modal-library-' + library.id());\n\n dom.addEventListener('click', callbackEvent);\n }\n\n dom = document.getElementById('designer-dialog-import-modal-from-file');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-file-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-library');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').show();\n $('#designer-dialog-import-modal-from-systems-form').hide();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').show();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-primary');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-default');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-modal-from-systems');\n dom.addEventListener('click', function click(event) {\n this.data(null);\n $('#designer-dialog-import-modal-from-library-form').hide();\n $('#designer-dialog-import-modal-from-systems-form').show();\n $('#designer-dialog-import-modal-from-file-form').hide();\n $('#designer-dialog-import-file-modal-import').hide();\n $('#designer-dialog-import-file-modal-merge').removeClass('btn-default');\n $('#designer-dialog-import-file-modal-merge').addClass('btn-primary');\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-import');\n dom.addEventListener('click', function click(event) {\n \n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-import-file-modal-file');\n dom.addEventListener('change', function click(e) {\n e.stopPropagation();\n e.preventDefault();\n \n var files = e.target.files,\n reader = new FileReader(),\n json = '',\n that = this;\n\n reader.onload = function onload(event) {\n json = json + event.target.result;\n };\n reader.onloadend = function onloadend() {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n that.data(sys);\n } else {\n that.data(null);\n } \n } catch (e) {\n that.data(null);\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-import-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n \n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-import-modal-from-file').prop('checked') ||\n $('#designer-dialog-import-modal-from-library').prop('checked')\n ) {\n if (this.data() && Object.keys(this.data()).length) {\n this.importSystem();\n }\n }\n if ($('#designer-dialog-import-modal-from-systems').prop('checked')) {\n if (this.data() && Object.keys(this.data()).length) {\n this.mergeSystem();\n }\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1948e18c6f1f038":{"_id":"n1948e18c6f1f038","component":"DialogImportFile","state":"show","action":"function show() {\n $('#designer-dialog-import-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"y1c99c14f7316ed0":{"_id":"y1c99c14f7316ed0","component":"DialogImportFile","state":"hide","action":"function hide() { \n $('#designer-dialog-import-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w13035176cd18ec0":{"_id":"w13035176cd18ec0","component":"DialogDropFile","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-file.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-file-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-merge');\n dom.addEventListener('click', function click(event) {\n this.require('factory').mergeSystem(this.data());\n \n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-file-modal-import');\n dom.addEventListener('click', function click(event) {\n var System = this.require('System'),\n sys = null,\n state = this.require('state'),\n message = this.require('message');\n\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n sys = this.require('factory').create(this.data());\n \n // empty log\n state.logs().forEach(function (item) {\n this.logs().pop();\n }.bind(state));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('designer').save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n this.require('designer').save();\n \n message.success('Importation of the system is done.');\t\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-file-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-file-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-file-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"i1c2891d03c165db":{"_id":"i1c2891d03c165db","component":"DialogDropFile","state":"show","action":"function show() { \n $('#designer-dialog-drop-file-modal').modal('show');\n}","useCoreAPI":false,"core":false},"w1ef271a5801083b":{"_id":"w1ef271a5801083b","component":"DialogDropFile","state":"hide","action":"function hide() { \n $('#designer-dialog-drop-file-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"o158c0125d313bc1":{"_id":"o158c0125d313bc1","component":"DialogTypeCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-type-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-type-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-type-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-type-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-type-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-type-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"f1bf26153e91a94e":{"_id":"f1bf26153e91a94e","component":"DialogTypeCreation","state":"show","action":"function show() { \n $('#designer-dialog-type-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1b7ef1af221063a":{"_id":"r1b7ef1af221063a","component":"DialogTypeCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-type-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"m1c6a71fad71fee1":{"_id":"m1c6a71fad71fee1","component":"DialogExport","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-export.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // default value\n if (system.master() === true) {\n $('#designer-dialog-export-isMaster').attr('checked', true);\n }\n\n //events\n dom = document.getElementById('designer-dialog-export-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-json');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').show();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-javascript');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-html');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-node');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-diagram-type').hide();\n $('#designer-dialog-export-options-log-level').show();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-export-graphviz');\n dom.addEventListener('click', function click(event) {\n $('#designer-dialog-export-options').hide();\n $('#designer-dialog-export-options-log-level').hide();\n $('#designer-dialog-export-options-diagram-type').show();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-export-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"j1c3811fb511de72":{"_id":"j1c3811fb511de72","component":"DialogExport","state":"show","action":"function show() { \n $('#designer-dialog-export-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o11bf7168fa1a773":{"_id":"o11bf7168fa1a773","component":"DialogExport","state":"hide","action":"function hide() { \n $('#designer-dialog-export-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"l15e6a1e7711d0ef":{"_id":"l15e6a1e7711d0ef","component":"DialogSchemaCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-schema-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-schema-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-schema-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-schema-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-schema-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-schema-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"d1118d16e2b12b21":{"_id":"d1118d16e2b12b21","component":"DialogSchemaCreation","state":"show","action":"function show() { \n $('#designer-dialog-schema-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"o121e11a6ee1db91":{"_id":"o121e11a6ee1db91","component":"DialogSchemaCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-schema-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"w1f7a8132f216d1c":{"_id":"w1f7a8132f216d1c","component":"DialogSystemCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-system-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-system-creation-name');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-system-creation-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-system-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-system-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-system-creation-name').focus();\n });\n}","useCoreAPI":false,"core":false},"e1e6ca1015e1d465":{"_id":"e1e6ca1015e1d465","component":"DialogSystemCreation","state":"show","action":"function show() { \n $('#designer-dialog-system-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m10f82178e11130e":{"_id":"m10f82178e11130e","component":"DialogSystemCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-system-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"l1188a196431b09d":{"_id":"l1188a196431b09d","component":"DialogModelCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-model-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n dom = document.getElementById('designer-dialog-model-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-model-creation-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n this.ok();\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"v1f50e113f9119f9":{"_id":"v1f50e113f9119f9","component":"DialogModelCreation","state":"show","action":"function show() { \n $('#designer-dialog-model-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t122401bc301f40a":{"_id":"t122401bc301f40a","component":"DialogModelCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-model-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"n1de871334c1351c":{"_id":"n1de871334c1351c","component":"DialogBehaviorCreation","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n selectStates = '',\n states = [],\n factory = this.require('factory'),\n space = this.require('state').space();\n\n $('#designer-dialog').empty();\n\n states = factory.getModelPaths(space);\n states.forEach(\n function (name) {\n selectStates = selectStates + '';\n });\n\n html = this.require('dialog-modal-behavior-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{states}}/gi, selectStates)\n );\n\n //events\n dom = document.getElementById('designer-dialog-behavior-creation-state');\n dom.addEventListener('keydown', function (event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-behavior-creation-state').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-behavior-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n // focus\n $('#designer-dialog-behavior-creation-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-behavior-creation-state').focus();\n });\n}","useCoreAPI":false,"core":false},"z134f51d13d1b4d0":{"_id":"z134f51d13d1b4d0","component":"DialogBehaviorCreation","state":"show","action":"function show() { \n $('#designer-dialog-behavior-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"b17f0312b751a46c":{"_id":"b17f0312b751a46c","component":"DialogBehaviorCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-behavior-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"q1b5f114b1c1e74e":{"_id":"q1b5f114b1c1e74e","component":"DialogComponentCreation","state":"init","action":"function init(conf) { \n var html = '',\n name = '',\n dom = null,\n selectModels = '',\n designer = this.require('designer'),\n models = this.require('factory').system().models();\n\n $('#designer-dialog').empty();\n\n for (name in models) {\n selectModels = selectModels + '';\n }\n\n html = this.require('dialog-modal-component-creation.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{models}}/gi, selectModels)\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-creation-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-component-creation-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n}","useCoreAPI":false,"core":false},"r1efd0102531db59":{"_id":"r1efd0102531db59","component":"DialogComponentCreation","state":"show","action":"function show() { \n $('#designer-dialog-component-creation-modal').modal('show');\n}","useCoreAPI":false,"core":false},"t1250217bbe111b1":{"_id":"t1250217bbe111b1","component":"DialogComponentCreation","state":"hide","action":"function hide() { \n $('#designer-dialog-component-creation-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"r1b0d81aa7d163d1":{"_id":"r1b0d81aa7d163d1","component":"DialogComponentInfo","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-component-info.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-component-info-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\t\n}","useCoreAPI":false,"core":false},"n10b6a1d0411f758":{"_id":"n10b6a1d0411f758","component":"DialogComponentInfo","state":"show","action":"function show() { \n $('#designer-dialog-component-info-modal').modal('show');\n}","useCoreAPI":false,"core":false},"n1cb8f1f6981f0b8":{"_id":"n1cb8f1f6981f0b8","component":"DialogComponentInfo","state":"hide","action":"function hide() { \n $('#designer-dialog-component-info-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"p14fb71056d1c4e5":{"_id":"p14fb71056d1c4e5","component":"DialogSearch","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system(),\n search = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-search.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n //events\n dom = document.getElementById('designer-dialog-search-modal-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-search-result');\n dom.addEventListener('click', function click(event) {\n this.hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-input-search');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() >= 0) {\n document.getElementsByClassName('list-group-item active')[0].click();\n } else {\n this.hide();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem('system-designer-search', event.target.value);\n }\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-search-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-search').focus();\n });\n\n // set old search if any\n if (typeof sessionStorage !== 'undefined') {\n search = sessionStorage.getItem('system-designer-search');\n if (search !== null) {\n $('#designer-dialog-input-search').val(search);\n this.filter(search);\n }\n }\n \n $('#designer-dialog-search-result-area').hide();\n}","useCoreAPI":false,"core":false},"i1f2a414c501ccef":{"_id":"i1f2a414c501ccef","component":"DialogSearch","state":"show","action":"function show() { \n $('#designer-dialog-search-modal').modal('show');\n}","useCoreAPI":false,"core":false},"m113f71766a1a35a":{"_id":"m113f71766a1a35a","component":"DialogSearch","state":"hide","action":"function hide() { \n $('#designer-dialog-search-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"a1782f14fca18eba":{"_id":"a1782f14fca18eba","component":"DialogExtension","state":"show","action":"function show() { \n $('#designer-dialog-extension-modal').modal('show');\n}","useCoreAPI":false,"core":false},"r1a97f1be45125db":{"_id":"r1a97f1be45125db","component":"DialogExtension","state":"hide","action":"function hide() { \n $('#designer-dialog-extension-modal').modal('hide');\n}","useCoreAPI":false,"core":false},"y1cef2194f4195d5":{"_id":"y1cef2194f4195d5","component":"DialogExtension","state":"init","action":"function init(conf) { \n\tvar html = '',\n dom = null,\n extensions = [],\n extensionsUninstalled = [],\n extension = '',\n listExtensions = '',\n listExtensionsUninstalled ='',\n systems = null,\n sys = '',\n system = null,\n length = 0,\n i = 0,\n that = this,\n nbExtensionToAdd = 0,\n nbExtensionUninstalled = 0,\n nbExtensionInstalled = 0,\n isSystemContainsExtension = false;\n\n $('.modal-backdrop').remove();\n $('#designer-dialog').empty();\n \n // init extensions list\n extensions = this.require('db').collections().Extension.find({\n 'installed': true\n });\n \n nbExtensionInstalled = extensions.length;\n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n listExtensions = listExtensions + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionInstalled === 0) {\n listExtensions = '

    No extension found

    ';\n }\n \n // init extensions uninstalled list\n extensionsUninstalled = this.require('db').collections().Extension.find({\n 'isCore': true\n });\n \n nbExtensionUninstalled = extensionsUninstalled.length;\n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n listExtensionsUninstalled = listExtensionsUninstalled + '' +\n '

    ' + extension.source().description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + extension.source().version + '

    ' +\n '
    ';\n }\n if (nbExtensionUninstalled === 0) {\n listExtensionsUninstalled = '

    No extension found

    ';\n }\n\n // init systems list\n systems = this.require('storage').get('system-designer-systems');\n if (systems) {\n systemIds = systems.systems;\n nbExtensionToAdd = systemIds.length;\n }\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n \n if (system && system.name.indexOf('extension-') !== -1) {\n isSystemContainsExtension = true;\n sys = sys + '' +\n '

    ' + system.description.substr(0, 40).split('\\n')[0].split('.')[0] + '

    ' +\n '

    v' + system.version + '

    ' +\n '
    ';\n }\n }\n \n if (nbExtensionToAdd === 0) {\n sys = '

    No extension found

    ';\n }\n\n html = this.require('dialog-modal-extension.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{extensions}}/gi, listExtensions)\n .replace(/{{uninstalled_extensions}}/gi, listExtensionsUninstalled)\n .replace(/{{systems}}/gi, sys)\n );\n \n // systems events \n var callbackSystemEvent = function cbSystemEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-systems-', '');\n\n that.data(that.require('storage').get(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n\n for (i = 0; i < nbExtensionToAdd; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system && system.name.indexOf('extension-') !== -1) {\n dom = document.getElementById('designer-dialog-extension-modal-systems-' + system._id);\n dom.addEventListener('click', callbackSystemEvent);\n }\n }\n \n // uninstalled extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-uninstalled-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionUninstalled; i++) {\n extension = this.require(extensionsUninstalled[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n\n // extensions events \n var callbackEvent = function cbEvent(event) {\n var id = '',\n libraries = null,\n length = 0,\n i = 0;\n\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n that.data(null);\n } else {\n id = this.getAttribute('id').replace('designer-dialog-extension-modal-extensions-', '');\n\n that.data(that.require(id));\n\n // remove old active\n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n\n // add current active\n $(this).addClass('active');\n }\n };\n \n for (i = 0; i < nbExtensionInstalled; i++) {\n extension = this.require(extensions[i]._id);\n\n dom = document.getElementById('designer-dialog-extension-modal-extensions-' + extension.id());\n dom.addEventListener('click', callbackEvent);\n }\n \n dom = document.getElementById('designer-dialog-extension-modal-action-remove');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').show();\n $('#designer-dialog-extension-modal-systems-area').hide();\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').hide();\n $('#designer-dialog-extension-modal-remove').show();\n $('#designer-dialog-extension-modal-add').hide();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-extension-modal-action-add');\n dom.addEventListener('click', function click(event) {\n var libraries = [],\n i = 0,\n length = 0;\n \n this.data(null);\n \n libraries = document.getElementById('designer-dialog-extension-modal-systems');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-uninstalled-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n libraries = document.getElementById('designer-dialog-extension-modal-extensions');\n length = libraries.children.length;\n for (i = 0; i < length; i++) {\n $(libraries.children[i]).removeClass('active');\n }\n \n $('#designer-dialog-extension-modal-extensions-area').hide();\n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n $('#designer-dialog-extension-modal-uninstalled-extensions-area').show();\n $('#designer-dialog-extension-modal-remove').hide();\n $('#designer-dialog-extension-modal-add').show();\n }.bind(this));\n \n // events\n dom = document.getElementById('designer-dialog-extension-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-add');\n dom.addEventListener('click', function click(event) {\n this.add();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal-remove');\n dom.addEventListener('click', function click(event) {\n this.remove();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-extension-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (this.data() && event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#designer-dialog-extension-modal-action-add').prop('checked')) {\n this.add();\n } else {\n this.remove(); \n }\n return false;\n }\n }.bind(this));\n \n if (isSystemContainsExtension) {\n $('#designer-dialog-extension-modal-systems-area').show();\n }\n}","useCoreAPI":false,"core":false},"u11da5146311bf9b":{"_id":"u11da5146311bf9b","component":"DialogExtension","state":"add","action":"function add() { \n\tvar Extension = this.require('Extension'),\n\tdata = this.data(),\n\tsystem = {},\n\textension = null,\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t},\n\tcleanJson = '',\n\treg = null,\n\tupdated = false,\n\tfromExtension = false;\n\t\n\tif (data && Object.keys(data).length) {\n \tif (data.isCore) {\n \t fromExtension = true;\n \t system = data.source();\n \t} else {\n \t system = this.data();\n \t}\n \n \tif (system && Object.keys(system).length) {\n \t \n \t if (!fromExtension) {\n \t // update or add extension\n \textensions = this.require('db').collections().Extension.find();\n \n extensions.forEach(function forEach(extension) {\n if (extension.source._id === system._id) {\n extension.source = system;\n updated = true;\n }\n });\n \n if (!updated) {\n \tnew Extension({\n \t 'source': system,\n \t 'installed': true\n \t});\n }\n \t } else {\n \t this.data().installed(true);\n \t }\n \n // save\n extensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \t// install extension\n \t// TODO put that in function\n \tif (updated) {\n \t this.require('runtime').stop('ext_' + system._id);\n \t this.require('runtime').uninstall('ext_' + system._id);\n \t}\n \t\n cleanJson = JSON.stringify(system);\n reg = new RegExp(system._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + system._id);\n system = JSON.parse(cleanJson);\n \n \tthis.require('runtime').install(system);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tthis.hide();\n \tthis.require('message').success('The extension has been added.');\n \t}\n\t}\n}","useCoreAPI":false,"core":false},"h125f41b82b19da2":{"_id":"h125f41b82b19da2","component":"DialogExtension","state":"remove","action":"function remove() { \n\tvar extension = this.data(),\n\textensions = [],\n\textensionToSave = {\n\t extensions: []\n\t};\n\t\n\tif (extension && Object.keys(extension).length) {\n \t// TODO put that in function\n \tthis.require('runtime').stop('ext_' + extension.source()._id);\n \tthis.require('runtime').uninstall('ext_' + extension.source()._id);\n \tthis.require('menubar').render();\n \tthis.require('toolbar').render();\n \t\n \tif (extension.isCore()) {\n \t extension.installed(false);\n \t} else {\n \t extension.destroy();\n \t}\n \t\n \t// extensions\n \textensions = this.require('db').collections().Extension.find();\n \t\n \textensionToSave.extensions = extensions.map(function map(extension) {\n \t var clean = JSON.parse(JSON.stringify(extension));\n \t delete clean.classInfo;\n \t return clean;\n \t});\n \n this.require('storage').set('system-designer-extensions', extensionToSave);\n \t\n \tthis.hide();\n \t\n \tthis.require('message').success('The extension has been removed.');\n\t}\n}","useCoreAPI":false,"core":false},"w1e8901ec6f110c0":{"_id":"w1e8901ec6f110c0","component":"DialogSearch","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"l199a81e07b123f5":{"_id":"l199a81e07b123f5","component":"DialogSearch","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [],\n nbItems = 0,\n nbResults = 0,\n numberResult = {};\n \n function showResult(str, index, value) {\n var result = '',\n length = value.length;\n \n result = str.substring(index - 20, index + length + 20);\n result = result.replace(/' + value + '');\n \n return result;\n } \n \n function showNumberResult(search, str) {\n var result = '',\n cleanSearch = '',\n reg = null,\n nb = null;\n \n cleanSearch = search.replace(/\\\\/g, '\\\\\\\\');\n cleanSearch = cleanSearch.replace(/\\(/g, '\\\\(');\n cleanSearch = cleanSearch.replace(/\\)/g, '\\\\)');\n cleanSearch = cleanSearch.replace(/\\[/g, '\\\\[');\n cleanSearch = cleanSearch.replace(/\\]/g, '\\\\]');\n cleanSearch = cleanSearch.replace(/\\./g, '\\\\.');\n cleanSearch = cleanSearch.replace(/\\+/g, '\\\\+');\n cleanSearch = cleanSearch.replace(/\\*/g, '\\\\*');\n cleanSearch = cleanSearch.replace(/\\$/g, '\\\\\\u0024');\n \n reg = new RegExp(cleanSearch, 'gi');\n nb = str.match(reg);\n \n if (nb && nb.length) {\n nbItems++;\n nbResults = nbResults + nb.length;\n result = '' + nb.length + '';\n }\n \n return {\n 'nb': nb.length,\n 'html': result\n };\n }\n \n function showInfoResult() {\n var info = '';\n \n if (nbResults > 1) {\n info = 'There are ' + nbResults + ' results';\n } else {\n info = 'There is '+ info + nbResults + ' result';\n }\n \n info = info + ' in ';\n \n if (nbItems > 1) {\n info = info + nbItems + ' elements';\n } else {\n info = info + nbItems + ' element';\n }\n \n if (nbResults > 0) {\n $('#designer-dialog-search-result-number').text(info);\n } else {\n $('#designer-dialog-search-result-number').text('');\n }\n }\n\n // clean\n document.getElementById('designer-dialog-search-result').innerHTML = '';\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n toSearch = JSON.stringify(schemas[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Schema ' + schemas[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // model\n for (id in models) {\n toSearch = JSON.stringify(models[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Model ' + models[id]._name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // type\n for (id in types) {\n toSearch = JSON.stringify(types[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Type ' + types[id].name + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // behavior\n for (id in behaviors) {\n toSearch = JSON.stringify(behaviors[id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + ' ' + numberResult.html + '

    ';\n }\n \n link = link + '

    ...' + showResult(behaviors[id].action, behaviors[id].action.toLowerCase().indexOf(value.toLowerCase()), value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n toSearch = JSON.stringify(components[collection][id]);\n index = toSearch.toLowerCase().indexOf(value.toLowerCase());\n if (index != -1) {\n numberResult = showNumberResult(value, toSearch);\n link = '' +\n '

    Component ' + components[collection][id]._id + ' ' + numberResult.html + '

    ' +\n '

    ...' + showResult(toSearch, index, value) + '...

    ' +\n '
    ';\n\n result.push({\n 'occurences': numberResult.nb,\n 'html': link\n });\n }\n }\n }\n \n result.sort(function (resultA, resultB) {\n if (resultA.occurences < resultB.occurences) {\n return 1;\n }\n if (resultA.occurences > resultB.occurences) {\n return -1;\n }\n return 0;\n });\n \n showInfoResult();\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push({\n 'occurences': 0,\n 'html': '

    There is no result for your search

    '\n });\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-search-result').innerHTML = result.map(function(res) {\n return res.html;\n }).join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-search-result-area').show();\n \n if (this.nbResult() > 0) {\n $('.list-group a:first')[0].scrollIntoView();\n }\n \n } else {\n $('#designer-dialog-search-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"q1767e1d52d10d30":{"_id":"q1767e1d52d10d30","component":"DialogCommand","state":"init","action":"function init(conf) { \n var html = '',\n dom = null,\n system = this.require('factory').system();\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-command.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',html.source());\n\n dom = document.getElementById('designer-dialog-input-command');\n dom.addEventListener('keyup', function keyup(event) {\n var currentSelection = 0;\n \n switch (true) {\n case event.keyCode === 37:\n case event.keyCode === 39:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 13:\n if (this.currentSelection() > -1) {\n $($('.list-group a')[this.currentSelection()]).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 38:\n currentSelection = this.currentSelection();\n if (currentSelection > 0) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection - 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n case event.keyCode === 40:\n currentSelection = this.currentSelection();\n if (currentSelection < this.nbResult() -1) {\n $($('.list-group a')[currentSelection]).removeClass('active');\n currentSelection = currentSelection + 1;\n this.currentSelection(currentSelection);\n $($('.list-group a')[currentSelection]).addClass('active');\n $($('.list-group a')[currentSelection])[0].scrollIntoView();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n this.filter(event.target.value);\n break;\n }\n }.bind(this));\n\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13 || event.keyCode === 38 || event.keyCode === 40) {\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n\n // focus\n $('#designer-dialog-command-modal').on('shown.bs.modal', function modal() {\n $('#designer-dialog-input-command').focus();\n });\n \n $('#designer-dialog-command-result-area').hide();\n}","useCoreAPI":false,"core":false},"v1b469169cd19052":{"_id":"v1b469169cd19052","component":"DialogCommand","state":"filter","action":"function filter(value) { \n var systemId = this.require('factory').system().id(),\n systemName = this.require('factory').system().name(),\n schemas = this.require('factory').system().schemas(),\n models = this.require('factory').system().models(),\n types = this.require('factory').system().types(),\n behaviors = this.require('factory').system().behaviors(),\n components = this.require('factory').system().components(),\n collection = '',\n id = '',\n toSearch = '',\n index = -1,\n result = [];\n \n // clean\n document.getElementById('designer-dialog-command-result').innerHTML = '';\n \n function hasValues(val, str) {\n var result = true,\n values = [];\n \n values = val.split(' ');\n \n values.forEach(function (value) {\n if (str.toLowerCase().indexOf(value.toLowerCase()) === -1) {\n result = false;\n }\n });\n \n return result;\n }\n\n if (value.length > 0 && value.trim() !== '') {\n\n // schema\n for (id in schemas) {\n if (hasValues(value, 'Schema ' + schemas[id]._name)) {\n link = '' +\n '

    Schema ' + schemas[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // model\n for (id in models) {\n if (hasValues(value, 'Model ' + models[id]._name)) {\n link = '' +\n '

    Model ' + models[id]._name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // type\n for (id in types) {\n if (hasValues(value, 'Type ' + types[id].name)) {\n link = '' +\n '

    Type ' + types[id].name + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n\n // behavior\n for (id in behaviors) {\n var fullName = behaviors[id].component + '.' + behaviors[id].state;\n if (behaviors[id].component === systemId) {\n fullName = systemName + '.' + behaviors[id].state;\n }\n if (hasValues(value, 'Behavior ' + fullName)) {\n link = '';\n \n if (behaviors[id].component === systemId) {\n link = link + '

    Behavior ' + systemName + '.' + behaviors[id].state + '

    ';\n } else { \n link = link + '

    Behavior ' + behaviors[id].component + '.' + behaviors[id].state + '

    ';\n }\n '
    ';\n\n result.push(link);\n }\n }\n\n // components\n for (collection in components) {\n for (id in components[collection]) {\n if (hasValues(value, 'Component' + components[collection][id]._id)) {\n link = '' +\n '

    Component ' + components[collection][id]._id + '

    ' +\n '
    ';\n\n result.push(link);\n }\n }\n }\n \n if (result.length === 0) {\n this.nbResult(0);\n result.push('

    There is no result

    ');\n } else {\n this.nbResult(result.length);\n }\n\n // result\n document.getElementById('designer-dialog-command-result').innerHTML = result.join(' ');\n \n if (this.nbResult() > 0) {\n $('.list-group a:first').addClass('active');\n this.currentSelection(0);\n } else {\n this.currentSelection(-1);\n }\n \n $('#designer-dialog-command-result-area').show();\n \n if (this.nbResult() > 0) {\n $($('.list-group a')[0])[0].scrollIntoView();\n }\n } else {\n $('#designer-dialog-command-result-area').hide();\n }\n}","useCoreAPI":false,"core":false},"v1626c1b34014385":{"_id":"v1626c1b34014385","component":"DialogCommand","state":"show","action":"function show() { \n $('#designer-dialog-command-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a10153101bc1a2ef":{"_id":"a10153101bc1a2ef","component":"DialogCommand","state":"hide","action":"function hide() { \n $('#designer-dialog-command-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"o1007d12b0a1a3e3":{"_id":"o1007d12b0a1a3e3","component":"DialogDelete","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.require('dialog-modal-delete.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // events\n dom = document.getElementById('designer-dialog-delete-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-delete-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-delete-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-delete-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"b190621a3cf139b0":{"_id":"b190621a3cf139b0","component":"DialogDelete","state":"hide","action":"function hide() { \n $('#designer-dialog-delete-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"z19b6c1e87e10065":{"_id":"z19b6c1e87e10065","component":"DialogDelete","state":"show","action":"function show() { \n $('#designer-dialog-delete-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"a110631fc9a10b17":{"_id":"a110631fc9a10b17","component":"DialogDelete","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"b1f8331ef3b19fb8":{"_id":"b1f8331ef3b19fb8","component":"DialogExport","state":"ok","action":"function ok() { \n var message = this.require('message');\n // code inspired from the blog post\n // https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/\n if (this.require('factory').system()) {\n var system = null,\n textToWrite = null,\n textFileAsBlob = null,\n fileNameToSaveAs = null,\n downloadLink = null;\n\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n switch (true) {\n case $('#designer-dialog-export-json').prop('checked'):\n textToWrite = this.require('export').toJSON($('#designer-dialog-export-isMaster').prop('checked'));\n fileNameToSaveAs = this.require('factory').system().name() + '.json';\n break;\n case $('#designer-dialog-export-javascript').prop('checked'):\n textToWrite = this.require('export').toJavaScript($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-html').prop('checked'):\n textToWrite = this.require('export').toHTML($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.html';\n break;\n case $('#designer-dialog-export-node').prop('checked'):\n textToWrite = this.require('export').toNode($('#designer-dialog-export-options-log-level-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.js';\n break;\n case $('#designer-dialog-export-graphviz').prop('checked'):\n textToWrite = this.require('export').toGraphviz($('#designer-dialog-export-options-diagram-type-select').val());\n fileNameToSaveAs = this.require('factory').system().name() + '.gv';\n break;\n default:\n break;\n }\n\n if (!this.require('designer').isElectron()) {\n\n textFileAsBlob = new Blob([textToWrite], {\n type: 'application/octet-stream'\n });\n\n if (navigator.msSaveBlob) {\n navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);\n } else {\n downloadLink = document.createElement('a');\n document.body.appendChild(downloadLink);\n downloadLink.style.display = 'none';\n \n downloadLink.download = fileNameToSaveAs;\n downloadLink.href = window.URL.createObjectURL(textFileAsBlob);\n \n downloadLink.click();\n window.URL.revokeObjectURL(downloadLink.href);\n }\n\n this.hide();\n } else {\n this.hide();\n\n var { dialog } = require('electron').remote;\n var fs = require('fs');\n var savePath = dialog.showSaveDialog({\n 'defaultPath': '~/' + fileNameToSaveAs\n });\n if (savePath) {\n fs.writeFile(savePath, textToWrite, function (err) {\n if (err) {\n message.danger('Exportation failed.');\n } else {\n message.success('Exportation is done.');\n }\n });\n }\n }\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"m1ce691dc881ef9b":{"_id":"m1ce691dc881ef9b","component":"DialogSystemCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n system = {},\n ModelSystem = null,\n modelSystem = null;\n \n function canCreate(name) {\n var systems = that.require('storage').get('system-designer-systems'),\n systemIds = [],\n i = 0,\n result = true;\n \n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n \n for (i = 0; i < length; i++) {\n system = that.require('storage').get(systemIds[i]);\n \n if (!system || system.name === name) {\n result = false;\n break;\n }\n }\n \n // internal default name\n if (name === 'default') {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-system-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '-').replace(/[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n \n system = this.require('factory').create({'name': name}, true);\n \n ModelSystem = this.require('ModelSystem');\n modelSystem = new ModelSystem({\n 'title': name\n });\n modelSystem.uuid = system._id;\n modelSystem.document(JSON.parse(JSON.stringify(system)));\n modelSystem.content(JSON.stringify(system));\n \n designer.save();\n \n this.hide();\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('System created. You can now begin to create schemas.');\n }\n}","useCoreAPI":false,"core":false},"z1b97f16c7f167ef":{"_id":"z1b97f16c7f167ef","component":"DialogSchemaCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n that = this,\n name = null,\n schema = {},\n ModelSchema = null,\n modelSchema = null;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-schema-creation-name').val();\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n schema = this.require('factory').addSchema(name);\n \n ModelSchema = this.require('ModelSchema');\n modelSchema = new ModelSchema({\n 'title': name\n });\n \n modelSchema.document(JSON.parse(JSON.stringify(schema)));\n modelSchema.content(JSON.stringify(schema));\n modelSchema.uuid(schema._id);\n \n this.require('designer').save();\n \n this.require('factory').createModel(schema);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateSchema(name, schema);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(schema._id);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.require('message').success('Schema created. A model has been also generated.');\n }\n}","useCoreAPI":false,"core":false},"x18f131fc0f15c28":{"_id":"x18f131fc0f15c28","component":"DialogModelCreation","state":"ok","action":"function ok() { \n this.hide();\n}","useCoreAPI":false,"core":false},"d1fe2a1b48a1ac00":{"_id":"d1fe2a1b48a1ac00","component":"DialogTypeCreation","state":"ok","action":"function ok() { \n var designer = this.require('designer'),\n name = null,\n isEnum = false,\n type = {},\n ModelType = null,\n modelType = null,\n id = '',\n that = this;\n \n function canCreate(name) {\n var result = true,\n id = '';\n \n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n \n if (that.require('factory').system().name() === name) {\n result = false;\n }\n \n return result;\n }\n \n // get value\n name = $('#designer-dialog-type-creation-name').val();\n isEnum = $('#designer-dialog-type-creation-isEnum')[0].checked;\n \n // clean\n name = name.trim();\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n \n if (name && canCreate(name)) {\n type = this.require('factory').addType(name, isEnum);\n \n ModelType = this.require('ModelType');\n modelType = new ModelType({\n 'title': name\n });\n modelType.uuid = name;\n modelType.document(JSON.parse(JSON.stringify(type)));\n modelType.content(JSON.stringify(type));\n \n designer.save();\n \n this.require('channel').$designerCreateType(name, type);\n \n this.hide();\n this.require('message-help').remove();\n \n this.require('state').space(name);\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('message').success('Type created. You can use it in your model.');\n }\n}","useCoreAPI":false,"core":false},"c147fb1fa4214beb":{"_id":"c147fb1fa4214beb","component":"DialogBehaviorCreation","state":"ok","action":"function ok() { \n var that = this, \n message = this.require('message'),\n behavior = {},\n ModelBehavior = null,\n modelBehavior = null,\n model = '',\n state = '',\n componentId = '';\n \n function _findSchemaId(compId) {\n var result = compId,\n modelName = '';\n \n for (modelName in that.require('factory').system().components()) {\n if (typeof that.require('factory').system().components()[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n \n // get value\n model = _findSchemaId(this.require('state').space());\n state = $('#designer-dialog-behavior-creation-state').val();\n componentId = this.require('state').space();\n \n behavior = this.require('factory').addBehavior(model, componentId, state);\n \n if (Object.keys(behavior).length) {\n ModelBehavior = this.require('ModelBehavior');\n \n modelBehavior = new ModelBehavior({\n 'uuid': behavior._id\n });\n \n modelBehavior.title(state);\n modelBehavior.document(behavior);\n modelBehavior.content(JSON.parse(JSON.stringify(behavior.action)));\n \n this.hide();\n this.require('message-help').remove();\n \n modelBehavior.render();\n \n Prism.highlightAll();\n \n // little effect\n $('#designer-behavior-' + behavior._id).hide();\n $('#designer-behavior-' + behavior._id).fadeIn(1000);\n \n this.require('designer').save();\n \n this.require('channel').$designerCreateBehavior(behavior);\n message.success('Behavior created.');\n } else {\n this.hide();\n message.warning('Can not create two behaviors for a method.');\n }\n}","useCoreAPI":false,"core":false},"h19e081c0c015dec":{"_id":"h19e081c0c015dec","component":"DialogImportFile","state":"mergeSystem","action":"function mergeSystem() { \n this.require('factory').mergeSystem(this.data());\n this.require('designer').save();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n}","useCoreAPI":false,"core":false},"k170351fdea1494e":{"_id":"k170351fdea1494e","component":"DialogImportFile","state":"importSystem","action":"function importSystem() { \n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n\n if (Object.keys(this.data()).length) {\n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n\n designer.save();\n\n this.require('state').space(sys.name());\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('router').update();\n\n this.hide();\n\n message.success('Importation of the system is done.');\n } else {\n message.danger('The system you try to import is invalid');\n }\n}","useCoreAPI":false,"core":false},"p1bc351895f16e0d":{"_id":"p1bc351895f16e0d","component":"DialogDropDiagram","state":"hide","action":"function hide() { \n\t $('#designer-dialog-drop-diagram-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"g1fa4c1f2b8146c3":{"_id":"g1fa4c1f2b8146c3","component":"DialogDropDiagram","state":"show","action":"function show() { \n $('#designer-dialog-drop-diagram-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"u1ab541be0216fb1":{"_id":"u1ab541be0216fb1","component":"DialogDropDiagram","state":"init","action":"function init(conf) { \n var html = null,\n dom = null;\n\n $('#designer-dialog').empty();\n\n html = this.require('dialog-modal-drop-diagram.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n //events\n dom = document.getElementById('designer-dialog-drop-diagram-modal-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n\n dom = document.getElementById('designer-dialog-drop-diagram-modal-import');\n dom.addEventListener('click', function click(event) {\n this.require('viz').render(this.data());\n this.require('viz').data(this.data());\n this.hide();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-drop-diagram-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n document.getElementById('designer-dialog-drop-diagram-modal-import').click();\n return false;\n }\n }.bind(this));\n\n if (!this.require('factory').system()) {\n $('#designer-dialog-drop-diagram-modal-merge').hide();\n }\n}","useCoreAPI":false,"core":false},"f560d27c-4105-4260-bf18-444a3d846cb0":{"_id":"f560d27c-4105-4260-bf18-444a3d846cb0","component":"DialogInstallPWA","state":"cancel","action":"function cancel() { \n\tthis.hide();\n}","useCoreAPI":false,"core":false},"cc1b0d4e-3767-49d8-8dc8-5f415446445c":{"_id":"cc1b0d4e-3767-49d8-8dc8-5f415446445c","component":"DialogInstallPWA","state":"show","action":"function show() { \n $('#designer-dialog-install-pwa-modal').modal('show');\t\n}","useCoreAPI":false,"core":false},"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0":{"_id":"d9f3f449-0d74-4348-8b0f-ed2c5f990dd0","component":"DialogInstallPWA","state":"hide","action":"function hide() { \n $('#designer-dialog-install-pwa-modal').modal('hide');\t\n}","useCoreAPI":false,"core":false},"ed9b0296-eb25-49bc-a623-9fb8082a33ec":{"_id":"ed9b0296-eb25-49bc-a623-9fb8082a33ec","component":"DialogInstallPWA","state":"init","action":"function init(conf) { \n var html = '',\n dom = null;\n\n // empty area\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n $('#designer-dialog').empty();\n \n // render\n html = this.require('dialog-modal-install-pwa.html');\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n );\n\n // events\n dom = document.getElementById('designer-dialog-install-pwa-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById('designer-dialog-install-pwa-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\n \n dom = document.getElementById('designer-dialog-install-pwa-modal');\n dom.addEventListener('keydown', function keydown(event) {\n if (event.keyCode === 13) {\n this.ok();\n event.stopPropagation();\n event.preventDefault();\n return false;\n }\n }.bind(this));\n \n // show\n $('#designer-dialog-install-pwa-modal').modal('show');\t\t\n}","useCoreAPI":false,"core":false},"af9fea82-f707-4dc6-bebc-67c35788472a":{"_id":"af9fea82-f707-4dc6-bebc-67c35788472a","component":"DialogInstallPWA","state":"ok","action":"function ok() { \n if (this.deferredPrompt() && this.deferredPrompt().prompt) {\n this.deferredPrompt().prompt();\n this.deferredPrompt().userChoice.then(function() {\n this.deferredPrompt(null);\n }.bind(this));\n } \n \n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.pwaInstalled = true;\n this.require('storage').set('system-designer-config', config);\n \n this.hide();\n}","useCoreAPI":false,"core":false},"1b6011ee4810caa":{"_id":"1b6011ee4810caa","component":"Editor","state":"getValue","action":"function getValue() { \n var result = '';\n \n switch (this.type()) {\n case 'ace':\n result = this.editor().getValue();\n break;\n case 'codemirror':\n result = this.editor().getValue();\n break;\n default:\n break;\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"18cfb1c93610ad4":{"_id":"18cfb1c93610ad4","component":"Editor","state":"setValue","action":"function setValue(val) { \n switch (this.type()) {\n case 'ace':\n result = this.editor().setValue(val);\n break;\n case 'codemirror':\n result = this.editor().setValue(val);\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"1a63c188a61e193":{"_id":"1a63c188a61e193","component":"Editor","state":"setEditor","action":"function setEditor(mode, value, lineNumber, autocomplete) {\n var language = {\n 'text': 'text/x-textile',\n 'json': 'application/json',\n 'javascript': 'text/javascript',\n 'html': 'htmlmixed',\n 'css': 'text/css'\n };\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().getSession().setTabSize(2);\n this.editor().focus();\n break;\n case 'behavior':\n if (mode === 'javascript') {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n \n if (this.require('state').menu() !== 'action') {\n return;\n }\n \n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n \n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption:'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption:'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption:'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption:'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption:'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption:'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption:'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption:'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n }\n }\n }\n }\n \n // snippets\n if (hasDot()) {\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'snippet' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'snippet' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'snippet' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'snippet' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'snippet' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'snippet' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setValue(value);\n\n this.editor().gotoLine(lineNumber);\n\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n } else {\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n }\n break;\n case 'component':\n this.editor().getSession().setMode('ace/mode/' + mode);\n this.editor().getSession().setTabSize(2);\n if (autocomplete) {\n this.editor().setOptions({\n enableLiveAutocompletion: true,\n });\n }\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n this.editor().focus();\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue('');\n this.editor().setOption('mode', language[mode]);\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"14e9517c531160a":{"_id":"14e9517c531160a","component":"Editor","state":"render","action":"function render() {\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n this.editor().getSession().setMode('ace/mode/text');\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().focus();\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n case 'schema':\n this.editor().getSession().setMode('ace/mode/json');\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var result = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', value: 'property', meta: 'type' });\n result.push({ name: 'property', caption: 'property', snippet: '\"$0\":\"property\",\\n', meta: \"add a property (snippet)\" });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'link', value: 'link', meta: 'type' });\n result.push({ name: 'link', caption: 'link', snippet: '\"$0\":\"link\",\\n', meta: 'add a link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'collection', value: 'collection', meta: 'type' });\n result.push({ name: 'collection', caption: 'collection', snippet: '\"$0\":\"collection\",\\n', meta: 'add a collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'method', value: 'method', meta: 'type' });\n result.push({ name: 'method', caption: 'method', snippet: '\"$0\":\"method\",\\n', meta: 'add a method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'event', value: 'event', meta: 'type' });\n result.push({ name: 'event', caption: 'event', snippet: '\"$0\":\"event\",\\n', meta: 'add an event (snippet)' });\n }\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"schema\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"schema\" });\n }\n }\n }\n\n callback(null, result);\n }.bind(this)\n };\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().getSession().setTabSize(2);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'model':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n result = [],\n types = {},\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n // helpers\n if ('dependency'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_dependency\", value: \"dependency\", meta: \"kind of relationship\" });\n }\n if ('aggregation'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_aggregation\", value: \"aggregation\", meta: \"kind of relationship\" });\n }\n if ('composition'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_composition\", value: \"composition\", meta: \"kind of relationship\" });\n }\n if ('normal'.indexOf(prefix) === 0) {\n result.push({ name: \"kind_normal\", value: \"normal\", meta: \"kind of relationship\" });\n }\n\n // snippets\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'property', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited property (snippet)' });\n }\n if ('link'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_link', caption: 'link', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', meta: 'override an inherited link (snippet)' });\n }\n if ('collection'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collection', caption: 'collection', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', meta: 'override an inherited collection (snippet)' });\n }\n if ('method'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_property', caption: 'method', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', meta: 'override an inherited method (snippet)' });\n }\n if ('event'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_event', caption: 'event', snippet: '\"$0\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', meta: 'override an inherited event (snippet)' });\n }\n\n if ('parameter'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_parameter', caption: 'parameter', snippet: '{\\n\\t\\\"name\\\": \\\"$0\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', meta: 'add a new parameter (snippet)' });\n }\n if ('default date'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_default_date', caption: 'default date', snippet: '1970-01-01T00:00:00.000Z', meta: 'set a default date value (snippet)' });\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { \"show\": 1000, \"hide\": 100 } });\n });\n break;\n case 'type':\n this.editor().getSession().setMode('ace/mode/json');\n this.editor().getSession().setTabSize(2);\n var langTools = ace.require('ace/ext/language_tools');\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n typeName = '',\n types = {},\n result = [],\n schemas = {};\n\n if ('any'.indexOf(prefix) === 0) {\n result.push({ name: \"any\", value: \"any\", meta: \"natif type\" });\n }\n if ('string'.indexOf(prefix) === 0) {\n result.push({ name: \"string\", value: \"string\", meta: \"natif type\" });\n }\n if ('number'.indexOf(prefix) === 0) {\n result.push({ name: \"number\", value: \"number\", meta: \"natif type\" });\n }\n if ('boolean'.indexOf(prefix) === 0) {\n result.push({ name: \"boolean\", value: \"boolean\", meta: \"natif type\" });\n }\n if ('date'.indexOf(prefix) === 0) {\n result.push({ name: \"date\", value: \"date\", meta: \"natif type\" });\n }\n if ('object'.indexOf(prefix) === 0) {\n result.push({ name: \"object\", value: \"object\", meta: \"natif type\" });\n }\n if ('array'.indexOf(prefix) === 0) {\n result.push({ name: \"array\", value: \"array\", meta: \"natif type\" });\n }\n if ('json'.indexOf(prefix) === 0) {\n result.push({ name: \"json\", value: \"json\", meta: \"alias\" });\n }\n if ('html'.indexOf(prefix) === 0) {\n result.push({ name: \"html\", value: \"html\", meta: \"alias\" });\n }\n if ('css'.indexOf(prefix) === 0) {\n result.push({ name: \"css\", value: \"css\", meta: \"alias\" });\n }\n if ('text'.indexOf(prefix) === 0) {\n result.push({ name: \"text\", value: \"text\", meta: \"alias\" });\n }\n if ('javascript'.indexOf(prefix) === 0) {\n result.push({ name: \"javascript\", value: \"javascript\", meta: \"alias\" });\n }\n\n // snippet\n if ('property'.indexOf(prefix) === 0) {\n result.push({ name: 'property', caption: 'property', snippet: '\\\"$0\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', meta: \"add a property (snippet)\" });\n }\n\n systemId = document.location.href.split('#')[2];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n if (types[typeName].name.indexOf(prefix) === 0) {\n result.push({ name: types[typeName].name, value: types[typeName].name, meta: \"custom type\" });\n }\n }\n if ('_Component'.indexOf(prefix) === 0) {\n result.push({ name: \"_Component\", value: \"_Component\", meta: \"model\" });\n }\n schemas = system.schemas;\n for (var name in schemas) {\n if (schemas[name]._name.indexOf(prefix) === 0) {\n result.push({ name: '' + schemas[name]._name, value: '' + schemas[name]._name, meta: \"model\" });\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'behavior':\n this.editor().getSession().setMode('ace/mode/javascript');\n this.editor().getSession().setTabSize(2);\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n\n var systemId = '',\n result = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function hasDot() {\n var result = false;\n if (editor.session.getLine(pos.row)[pos.column - 1 - prefix.length] === '.') {\n result = true;\n }\n return result;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 && prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1];\n systemId = document.location.href.split('#')[2];\n\n system = this.require('storage').get(systemId);\n\n if (system && hasDot()) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0 && name.indexOf(prefix) === 0) {\n result.push({ name: name, caption: name, snippet: name + '($0)', meta: schema[name] });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n if ('id'.indexOf(prefix) === 0) {\n result.push({ name: 'id', caption: 'id', snippet: 'id()', meta: 'property (inherited)' });\n }\n if ('classInfo'.indexOf(prefix) === 0) {\n result.push({ name: 'classInfo', caption: 'classInfo', snippet: 'classInfo()', meta: 'method (inherited)' });\n }\n if ('on'.indexOf(prefix) === 0) {\n result.push({ name: 'on', caption: 'on', snippet: 'on($0)', meta: 'method (inherited)' });\n }\n if ('off'.indexOf(prefix) === 0) {\n result.push({ name: 'off', caption: 'off', snippet: 'off($0)', meta: 'method (inherited)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'require', caption: 'require', snippet: 'require(\\'$0\\')', meta: 'method (inherited)' });\n }\n if ('destroy'.indexOf(prefix) === 0) {\n result.push({ name: 'destroy', caption: 'destroy', snippet: 'destroy()', meta: 'method (inherited)' });\n }\n if ('init'.indexOf(prefix) === 0) {\n result.push({ name: 'init', caption: 'init', snippet: 'init($0)', meta: 'method (inherited)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'error', caption: 'error', snippet: 'error($0)', meta: 'event (inherited)' });\n }\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0 & prop.indexOf(prefix) === 0) {\n result.push({ name: prop, caption: prop, snippet: prop + '($0)', meta: schema[prop] + ' (inherited)' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n if (!hasDot()) {\n // snippets\n if ('collections'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_collections', caption: 'collections', snippet: 'this.require(\\'db\\').collections()', meta: 'get a collection (snippet)' });\n }\n if ('require'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_require', caption: 'require', snippet: 'this.require(\\'$0\\')', meta: 'require a component (snippet)' });\n }\n if ('debug'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_debug', caption: 'debug', snippet: 'this.require(\\'logger\\').debug(\\'$0\\')', meta: 'log a debug message (snippet)' });\n }\n if ('info'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_info', caption: 'info', snippet: 'this.require(\\'logger\\').info(\\'$0\\')', meta: 'log an info message (snippet)' });\n }\n if ('warn'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_warn', caption: 'warn', snippet: 'this.require(\\'logger\\').warn(\\'$0\\')', meta: 'log a warning message (snippet)' });\n }\n if ('error'.indexOf(prefix) === 0) {\n result.push({ name: 'snip_error', caption: 'error', snippet: 'this.require(\\'logger\\').error(\\'$0\\')', meta: 'log an error message (snippet)' });\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n // uncomment to add more autocomplete\n //var langtools = ace.require(\"ace/ext/language_tools\");\n //langtools.addCompleter(completer);\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n //enableLiveAutocompletion: true\n });\n this.editor().setShowPrintMargin(false);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n this.editor().focus();\n break;\n case 'component':\n this.editor().setShowPrintMargin(false);\n this.editor().getSession().setTabSize(2);\n this.editor().setReadOnly(false);\n this.editor().$blockScrolling = Infinity;\n this.editor().setValue('');\n\n var completer = {\n getCompletions: function (editor, session, pos, prefix, callback) {\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n result = [];\n\n systemId = document.location.href.split('#')[3];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n if (components[modelName][componentId]._id.indexOf(prefix) === 0) {\n result.push({ name: componentId, value: componentId, meta: modelName });\n }\n }\n }\n }\n\n result.sort(function (a, b) {\n if (a.name > b.name) {\n return 1;\n }\n if (a.name < b.name) {\n return -1;\n }\n return 0;\n }\n );\n callback(null, result);\n }.bind(this)\n };\n\n this.editor().setOptions({\n enableLiveAutocompletion: [completer]\n });\n\n this.editor().commands.addCommand({\n name: 'myCommand',\n bindKey: { win: 'Ctrl-S', mac: 'Command-S' },\n exec: function (editor) {\n runtime.require('designer').save();\n }\n });\n this.editor().commands.addCommand({\n name: 'gotoCommand',\n bindKey: { win: 'Ctrl-O', mac: 'Command-O' },\n exec: function (editor) {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({ 'title': '' });\n dialog.show();\n }\n }\n });\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n this.editor().addKeyMap({\n \"Cmd-S\": function () { runtime.require('designer').save() },\n \"Ctrl-S\": function () { runtime.require('designer').save() }\n });\n break;\n\n case 'schema':\n var snippets = [];\n var system = '';\n var schemas = '';\n var systemId = '';\n\n // snippets and helpers\n snippets.push({ searchText: 'property', text: 'property', displayText: 'property (type)' });\n snippets.push({ searchText: 'property', text: '\"\":\"property\"', displayText: 'add a property (snippet)' });\n\n snippets.push({ searchText: 'link', text: 'link', displayText: 'link (type)' });\n snippets.push({ searchText: 'link', text: '\"\":\"link\"', displayText: 'add a link (snippet)' });\n\n snippets.push({ searchText: 'collection', text: 'collection', displayText: 'collection (type)' })\n snippets.push({ searchText: 'collection', text: '\"\":\"collection\"', displayText: 'add a collection (snippet)' });\n\n snippets.push({ searchText: 'method', text: 'method', displayText: 'method (type)' })\n snippets.push({ searchText: 'method', text: '\"\":\"method\"', displayText: 'add a method (snippet)' });\n\n snippets.push({ searchText: 'event', text: 'event', displayText: 'event (type)' })\n snippets.push({ searchText: 'event', text: '\"\":\"event\"', displayText: 'add an event (snippet)' });\n\n // schemas\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n snippets.push({ searchText: '_Component', text: '_Component', displayText: '_Component (schema)' });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + ' (schema)' });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'model':\n var systemId = '',\n modelId = '',\n modelName = '',\n typeName = '',\n snippets = [],\n types = {},\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \" any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n modelId = document.location.href.split('#')[1].split('#')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n // helpers\n snippets.push({ searchText: \"dependency\", text: \"dependency\", displayText: \"dependency (kind of relationship)\" });\n snippets.push({ searchText: \"aggregation\", text: \"aggregation\", displayText: \"aggregation (kind of relationship)\" });\n snippets.push({ searchText: \"composition\", text: \"composition\", displayText: \"composition (kind of relationship)\" });\n snippets.push({ searchText: \"normal\", text: \"normal\", displayText: \"normal (kind of relationship)\" });\n\n // snippets\n snippets.push({ searchText: 'property', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited property (snippet)' });\n snippets.push({ searchText: 'link', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"_Component\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}\\t', displayText: 'override an inherited link (snippet)' });\n snippets.push({ searchText: 'collection', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"[_Component]\\\",\\n\\t\\\"kind\\\": \\\"normal\\\",\\n\\t\\\"readOnly\\\": false,\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": []\\n}\\t', displayText: 'override an inherited collection (snippet)' });\n snippets.push({ searchText: 'method', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t},\\n\\t\\\"result\\\": \\\"any\\“\\n}\\t', displayText: 'override an inherited method (snippet)' });\n snippets.push({ searchText: 'event', text: '\"\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"params\\\": {\\n\\t\\t\\\"name\\\": \\\"param\\\",\\n\\t\\t\\\"description\\\": \\\"\\\",\\n\\t\\t\\\"type\\\": \\\"any\\\",\\n\\t\\t\\\"mandatory\\\": false,\\n\\t\\t\\\"default\\\": null\\n\\t}\\n}', displayText: 'override an inherited event (snippet)' });\n snippets.push({ searchText: 'parameter', text: '{\\n\\t\\\"name\\\": \\\"\\\",\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": null\\n}\\t', displayText: 'add a new parameter (snippet)' });\n\n snippets.push({ searchText: 'default date', text: '1970-01-01T00:00:00.000Z', displayText: 'set a default date value (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'type':\n var systemId = '',\n typeName = '',\n types = {},\n snippets = [],\n schemas = {};\n\n snippets.push({ searchText: \"any\", text: \"any\", displayText: \"any (natif type)\" });\n snippets.push({ searchText: \"string\", text: \"string\", displayText: \"string (natif type)\" });\n snippets.push({ searchText: \"number\", text: \"number\", displayText: \"number (natif type)\" });\n snippets.push({ searchText: \"boolean\", text: \"boolean\", displayText: \"boolean (natif type)\" });\n snippets.push({ searchText: \"date\", text: \"date\", displayText: \"date (natif type)\" });\n snippets.push({ searchText: \"object\", text: \"object\", displayText: \"object (natif type)\" });\n snippets.push({ searchText: \"array\", text: \"array\", displayText: \"array (natif type)\" });\n snippets.push({ searchText: \"json\", text: \"json\", displayText: \"json (alias)\" });\n snippets.push({ searchText: \"html\", text: \"html\", displayText: \"html (alias)\" });\n snippets.push({ searchText: \"css\", text: \"css\", displayText: \"css (alias)\" });\n snippets.push({ searchText: \"text\", text: \"text\", displayText: \"text (alias)\" });\n snippets.push({ searchText: \"javascript\", text: \"javascript\", displayText: \"javascript (alias)\" });\n\n // snippet\n snippets.push({ searchText: 'property', text: '\\\"\\\": {\\n\\t\\\"description\\\": \\\"\\\",\\n\\t\\\"type\\\": \\\"any\\\",\\n\\t\\\"mandatory\\\": false,\\n\\t\\\"default\\\": \\\"\\\"\\n}', displayText: \"Add a property (snippet)\" });\n\n systemId = document.location.href.split('#')[2].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n types = system.types;\n for (typeName in types) {\n snippets.push({ searchText: types[typeName].name, text: types[typeName].name, displayText: types[typeName].name + \" (custom type)\" });\n }\n\n snippets.push({ searchText: \"_Component\", text: \"_Component\", displayText: \"_Component (model)\" });\n schemas = system.schemas;\n for (var name in schemas) {\n snippets.push({ searchText: schemas[name]._name, text: schemas[name]._name, displayText: schemas[name]._name + \" (model)\" });\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n\n break;\n\n case 'behavior':\n var systemId = '',\n snippets = [],\n behavior = {},\n schemaName = '',\n schemas = {},\n schema = {},\n parents = {},\n i = 0;\n\n if (this.require('state').menu() !== 'action') {\n return;\n }\n\n function _searchApis(parents) {\n var length = 0,\n i = 0;\n\n if (parents) {\n length = parents.length;\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n function _getSchema(schemas, name) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _findSchemaName(id, components) {\n var result = id,\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n id = document.location.href.split('#')[1].split('?')[0];\n systemId = document.location.href.split('#')[2].split('?')[0];\n\n system = this.require('storage').get(systemId);\n\n if (system) {\n schemaName = _findSchemaName(system.behaviors[id].component, this.require('factory').system().components());\n schemas = system.schemas;\n\n schema = _getSchema(schemas, schemaName);\n\n for (var name in schema) {\n if (name.indexOf('_') !== 0) {\n snippets.push({ searchText: name, text: name + '()', displayText: name + ' (' + schema[name] + ')' });\n }\n }\n\n // case of system\n if (system.behaviors[id].component === systemId) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n }\n\n // inherited\n parents = schema._inherit;\n if (parents) {\n length = parents.length;\n\n for (i = 0; i < length; i++) {\n if (parents[i].indexOf('_Component') !== -1) {\n snippets.push({ searchText: 'id', text: 'id()', displayText: 'id (inherited property)' });\n snippets.push({ searchText: 'classInfo', text: 'classInfo()', displayText: 'classInfo (inherited method)' });\n snippets.push({ searchText: 'on', text: 'on()', displayText: 'on (inherited method)' });\n snippets.push({ searchText: 'off', text: 'off()', displayText: 'off (inherited method)' });\n snippets.push({ searchText: 'require', text: 'require(\\'\\')', displayText: 'require (inherited method)' });\n snippets.push({ searchText: 'destroy', text: 'destroy()', displayText: 'destroy (inherited method)' });\n snippets.push({ searchText: 'init', text: 'init()', displayText: 'init (inherited method)' });\n snippets.push({ searchText: 'error', text: 'error()', displayText: 'error (inherited method)' });\n } else {\n schema = _getSchema(schemas, parents[i]);\n\n for (var prop in schema) {\n if (prop.indexOf('_') !== 0) {\n snippets.push({ searchText: prop, text: prop + '()', displayText: prop + ' (inherited ' + schema[prop] + ')' });\n }\n }\n if (typeof schema._inherit !== 'undefined') {\n _searchApis(schema._inherit);\n }\n }\n }\n }\n }\n\n // snippets\n snippets.push({ searchText: 'collections', text: 'this.require(\\'db\\').collections()', displayText: 'get a collection (snippet)' });\n snippets.push({ searchText: 'require', text: 'this.require(\\'\\')', displayText: 'require a component (snippet)' });\n snippets.push({ searchText: 'debug', text: 'this.require(\\'logger\\').debug(\\'\\')', displayText: 'log a debug message (snippet)' });\n snippets.push({ searchText: 'info', text: 'this.require(\\'logger\\').info(\\'\\')', displayText: 'log an info message (snippet)' });\n snippets.push({ searchText: 'warn', text: 'this.require(\\'logger\\').warn(\\'\\')', displayText: 'log a warning message (snippet)' });\n snippets.push({ searchText: 'error', text: 'this.require(\\'logger\\').error(\\'\\')', displayText: 'log an error message (snippet)' });\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n\n if (currentWord && currentWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(currentWord) >= 0\n })\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n\n case 'component':\n var systemId = '',\n system = '',\n modelName = '',\n componentId = '',\n components = {},\n snippets = [];\n\n systemId = document.location.href.split('#')[3].split('?')[0];\n system = this.require('storage').get(systemId);\n\n if (system) {\n components = system.components;\n for (modelName in components) {\n for (componentId in components[modelName]) {\n snippets.push({ searchText: componentId, text: componentId, displayText: componentId + ' (' + modelName + ')' });\n }\n }\n }\n\n function showAutocomplete() {\n CodeMirror.showHint(runtime.require('editor').editor(), function () {\n var cursor = runtime.require('editor').editor().getCursor();\n var token = runtime.require('editor').editor().getTokenAt(cursor);\n var start = token.start;\n var end = cursor.ch;\n var line = cursor.line;\n var currentWord = token.string;\n var list = [];\n var cleanWord = currentWord.replace(/\"/g, '');\n\n if (cleanWord && cleanWord.length > 1) {\n list = snippets.filter(function (item) {\n return item.searchText.indexOf(cleanWord) >= 0\n })\n }\n\n if (currentWord && currentWord[0] === '\"') {\n start = start + 1;\n }\n\n return {\n list: list,\n from: CodeMirror.Pos(line, start),\n to: CodeMirror.Pos(line, end)\n }\n }, { completeSingle: false })\n }\n\n this.editor().on('keyup', function (cm, event) {\n if (\n !cm.state.completionActive &&\n event.keyCode != 13 &&\n event.keyCode != 37 &&\n event.keyCode != 39 &&\n event.keyCode != 38 &&\n event.keyCode != 40 &&\n event.keyCode != 222 &&\n event.keyCode != 51\n ) {\n showAutocomplete();\n }\n });\n this.editor().addKeyMap({\n 'Cmd-S': function () { runtime.require('designer').save() },\n 'Ctrl-S': function () { runtime.require('designer').save() }\n });\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"11df21f30c14808":{"_id":"11df21f30c14808","component":"Editor","state":"initValue","action":"function initValue(value, lineNumber) {\n var that = this;\n\n switch (this.type()) {\n case 'ace':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n break;\n case 'behavior':\n this.editor().setValue(value);\n this.editor().gotoLine(lineNumber);\n this.editor().getSession().$undoManager.reset();\n this.editor().getSession().setUndoManager(new ace.UndoManager());\n\n var Range = ace.require('ace/range').Range;\n var endLine = value.indexOf('{') + 1;\n\n this.editor().session.addMarker(new Range(0, 0, 0, endLine), 'readonly');\n\n // readonly\n this.editor().keyBinding.addKeyboardHandler({\n handleKeyboard: function (data, hash, keyString, keyCode, event) {\n var result = null;\n\n switch (true) {\n case (hash === -1 || (keyCode <= 40 && keyCode >= 37)):\n result = false;\n break;\n case intersects(new Range(0, 0, 0, endLine)):\n if (event.keyCode !== 67 && event.keyCode !== 70) {\n result = {\n command: 'null',\n passEvent: false\n };\n\n if (event.keyCode !== 91 && event.keyCode !== 17) {\n runtime.require('message').warning('You can not modify the header of the behavior.');\n }\n } else {\n result = false;\n }\n break;\n default:\n break;\n }\n\n if (result) {\n return result;\n }\n }\n });\n\n function intersects(range) {\n var result = false,\n selection = that.editor().getSelectionRange();\n\n result = (selection.end.row === 0 && selection.end.column < endLine + 1) && selection.intersects(range) && that.require('state').menu() === 'action';\n return result;\n }\n break;\n case 'component':\n break;\n default:\n break;\n }\n break;\n case 'codemirror':\n switch (this.context()) {\n case 'system':\n case 'schema':\n case 'model':\n case 'type':\n case 'behavior':\n case 'component':\n this.editor().setValue(value);\n this.editor().setCursor({\n line: lineNumber - 1,\n ch: 0\n });\n this.editor().clearHistory();\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"z17c861b9211fe8c":{"_id":"z17c861b9211fe8c","component":"Editor","state":"undo","action":"function undo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().undo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"i132801925d14b80":{"_id":"i132801925d14b80","component":"Editor","state":"redo","action":"function redo() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.editor().redo();\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"s1134312b151d82d":{"_id":"s1134312b151d82d","component":"Editor","state":"selectAll","action":"function selectAll() {\n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n this.editor().selectAll();\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n this.require('editor').editor().setSelection({\n line: this.require('editor').editor().firstLine(),\n ch: 0\n }, {\n line: this.require('editor').editor().lastLine() + 1,\n ch: 0\n });\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"o1b84c1595615c6f":{"_id":"o1b84c1595615c6f","component":"Editor","state":"copy","action":"function copy() { \n switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n case 'codemirror':\n this.require('editor').editor().focus();\n document.execCommand('copy');\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"e180711f2cf19133":{"_id":"e180711f2cf19133","component":"Editor","state":"paste","action":"function paste() { \n\t switch (this.type()) {\n case 'ace':\n this.require('editor').editor().focus();\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n case 'codemirror':\n if (!document.execCommand('paste', null, null)) {\n // TODO\n }\n break;\n default:\n break;\n\t }\n}","useCoreAPI":false,"core":false},"p14b27128f61643e":{"_id":"p14b27128f61643e","component":"Export","state":"toJSON","action":"function toJSON(isMaster) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n system = JSON.parse(JSON.stringify(system));\n\n if (isMaster) {\n system.master = true;\n } else {\n system.master = false;\n }\n\n return JSON.stringify(system);\n}","useCoreAPI":false,"core":false},"g131c91154e14849":{"_id":"g131c91154e14849","component":"Export","state":"toHTML","action":"function toHTML(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('export-app.html').source();\n\n source = source\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, function (val) { return JSON.stringify(system) });\n\n return source;\n}","useCoreAPI":false,"core":false},"r11d81144f810201":{"_id":"r11d81144f810201","component":"Export","state":"toNode","action":"function toNode(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('app.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val())\n .replace(/{{system}}/g, JSON.stringify(system));\n\n return source;\n}","useCoreAPI":false,"core":false},"h14919197fb17aaf":{"_id":"h14919197fb17aaf","component":"Export","state":"toJavaScript","action":"function toJavaScript(logLevel) {\n var system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n var source = this.require('javascript-export.js').source();\n\n source = source\n .replace(/{{version}}/g, this.require('factory').system().version())\n .replace(/{{description}}/g, this.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{name}}/g, this.require('factory').system().name())\n .replace(/{{logLevel}}/g, $('#designer-dialog-export-options-log-level-select').val());\n\n // SYSTEM\n\n var confSystem = {};\n\n confSystem._id = system._id;\n confSystem.name = system.name;\n confSystem.version = system.version;\n confSystem.description = system.description;\n\n source = source + '/**\\n';\n source = source + ' * System ' + confSystem.name + '\\n';\n source = source + ' * @system\\n';\n source = source + ' */\\n';\n source = source + 'runtime.system(' + JSON.stringify(confSystem, null, '\\t', 2) + ');\\n\\n';\n\n // SCHEMA / MODEL / TYPE \n if (Object.keys(system.schemas).length > 0 || Object.keys(system.types).length > 0) {\n source = source + '\\n// Schemas, models and types creation\\n\\n\\n';\n }\n\n var name = '';\n var schemaSorted = [];\n var schemaNameSorted = [];\n var schemaName = {};\n\n for (name in system.schemas) {\n schemaSorted.push(system.schemas[name]);\n schemaNameSorted.push(system.schemas[name]._name);\n schemaName[system.schemas[name]._name] = system.schemas[name]._name;\n }\n schemaSorted.sort(function (schemaA, schemaB) {\n return schemaA._name > schemaB._name;\n });\n schemaNameSorted.sort();\n\n schemaSorted.forEach(function (schema) {\n source = source + '/**\\n';\n source = source + ' * Schema ' + schema._name + '\\n';\n source = source + ' * @schema\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').schema(' + JSON.stringify(schema, null, '\\t', 2) + ');\\n\\n';\n });\n\n var modelSorted = [];\n var modelNameSorted = [];\n for (name in system.models) {\n modelSorted.push(system.models[name]);\n modelNameSorted.push(system.models[name]._name);\n }\n modelSorted.sort(function (modelA, modelB) {\n return modelA._name > modelB._name;\n });\n modelNameSorted.sort();\n\n modelSorted.forEach(function (model) {\n source = source + '/**\\n';\n source = source + ' * Model ' + model._name + '\\n';\n source = source + ' * @model\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').model(' + JSON.stringify(model, null, '\\t', 2) + ');\\n\\n';\n });\n\n var typeSorted = [];\n var typeNameSorted = [];\n for (name in system.types) {\n typeSorted.push(system.types[name]);\n typeNameSorted.push(system.types[name].name);\n }\n typeSorted.sort(function (typeA, typeB) {\n return typeA.name > typeB.name;\n });\n typeNameSorted.sort();\n\n typeSorted.forEach(function (type) {\n source = source + '/**\\n';\n source = source + ' * Type ' + type.name + '\\n';\n source = source + ' * @type\\n';\n source = source + ' */\\n';\n source = source + 'runtime.require(\\'metamodel\\').type(' + JSON.stringify(type, null, '\\t', 2) + ');\\n\\n';\n });\n\n if (Object.keys(system.schemas).length > 0 || Object.keys(system.models).length > 0 || Object.keys(system.types).length > 0) {\n source = source + 'runtime.require(\\'metamodel\\').create();\\n\\n';\n }\n\n // COMPONENT \n if (Object.keys(system.components).length > 0) {\n source = source + '\\n// Components creation\\n\\n\\n';\n }\n schemaNameSorted.forEach(function (collection) {\n for (name in system.components[collection]) {\n source = source + '/**\\n';\n source = source + ' * Component ' + system.components[collection][name]._id + '\\n';\n source = source + ' * @component\\n';\n source = source + ' */\\n';\n source = source + 'new (runtime.require(\\'' + collection + '\\'))(' + JSON.stringify(system.components[collection][name], null, '\\t', 2) + ');\\n\\n';\n }\n });\n\n // BEHAVIOR \n if (Object.keys(system.behaviors).length > 0) {\n source = source + '\\n// Behaviors creation\\n\\n\\n';\n }\n\n var behaviors = {};\n var behaviorsComponentNameSorted = [];\n var modelsByName = {};\n\n for (name in system.behaviors) {\n if (typeof behaviors[system.behaviors[name].component] === 'undefined') {\n behaviors[system.behaviors[name].component] = [];\n }\n behaviors[system.behaviors[name].component].push(system.behaviors[name]);\n }\n\n behaviorsComponentNameSorted = Object.keys(behaviors);\n behaviorsComponentNameSorted.sort();\n\n var id = '';\n for (id in system.models) {\n modelsByName[system.models[id]._name] = system.models[id];\n }\n\n behaviorsComponentNameSorted.forEach(function forEach(componentName) {\n var componentBehaviors = behaviors[componentName];\n\n componentBehaviors.sort(function sort(behaviorA, behaviorB) {\n return behaviorA.state > behaviorB.state;\n });\n\n if (componentBehaviors.length > 0) {\n if (componentName === system._id) {\n source = source + '// system behaviors\\n\\n';\n } else {\n source = source + '// ' + componentName + ' behaviors\\n\\n';\n }\n }\n\n componentBehaviors.forEach(function forEach(behavior) {\n var useCoreAPI = typeof behavior.useCoreAPI !== 'undefined' ? behavior.useCoreAPI : false;\n var core = typeof behavior.core !== 'undefined' ? behavior.core : false;\n var comp = '';\n var behaviorParamDef = {};\n var options = ');\\n\\n';\n\n if (useCoreAPI && !core) {\n options = ', true);\\n\\n';\n }\n if (useCoreAPI && core) {\n options = ', true, true);\\n\\n';\n }\n\n source = source + '/**\\n';\n source = source + ' * @method ' + behavior.state + '\\n';\n\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].params) {\n modelsByName[behavior.component][behavior.state].params.forEach(function forEach(param) {\n source = source + ' * @param {' + param.type + '} ' + param.name + '\\n';\n });\n }\n if (modelsByName[behavior.component] && modelsByName[behavior.component][behavior.state] && modelsByName[behavior.component][behavior.state].result) {\n source = source + ' * @returns {' + modelsByName[behavior.component][behavior.state].result + '} \\n';\n }\n\n source = source + ' */\\n';\n\n switch (true) {\n case behavior.component === system._id:\n comp = 'runtime.system()';\n break;\n default:\n comp = 'runtime.require(\\'' + behavior.component + '\\')';\n break;\n }\n\n source = source + comp + '.on(\\'' + behavior.state + '\\', ' + behavior.action + options;\n })\n });\n\n // START\n source = source + '// Start the system\\n';\n source = source + 'runtime.system().start();\\n';\n\n return source;\n}","useCoreAPI":false,"core":false},"e13c7916b1a15fc4":{"_id":"e13c7916b1a15fc4","component":"Export","state":"toGraphviz","action":"function toGraphviz(diagramType) {\n var schemas = this.require('factory').system().schemas();\n var models = this.require('factory').system().models();\n var types = this.require('factory').system().types();\n var components = this.require('factory').system().components();\n var inheritance = '';\n var modelId = '';\n var typeId = '';\n var componentId = '';\n var modelName = '';\n var typeName = '';\n var modelDescription = '';\n var propName = '';\n var propVal = '';\n var propDef = '';\n var attributes = '';\n var methods = '';\n var result = '';\n var dependencies = '';\n var instancesOf = '';\n var links = '';\n var collections = '';\n var instances = '';\n var that = this;\n var keys = [];\n var sortedKeys = {};\n var generatedDiagram = '';\n var parents = '';\n var modelNames = [];\n var modelDef = {};\n var schemaDef = {};\n var incoming = '';\n var outgoing = '';\n var edges = '';\n var relationships = '';\n var instancesRelation ='';\n var kindToEdgeStyle = {\n 'normal': 'none',\n 'dependency': 'vee',\n 'composition': 'diamond',\n 'aggregation': 'odiamond'\n };\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _isType(name) {\n return typeof types[name] !== 'undefined';\n }\n\n function _clean(text) {\n return text.replace(/\\{/g, '').replace(/\\}/g, '');\n }\n\n function _cleanName(text) {\n return text.toString()\n .replace(/\\'/g, ' ')\n .replace(/\\./g, '')\n .replace(/\\-/g, '')\n //.replace(/node/i, '_node')\n .replace(/edge/i, '_edge')\n .replace(/graph/i, '_graph')\n .replace(/digraph/i, '_digraph')\n .replace(/subgraph/i, '_subgraph')\n .replace(/strict/i, '_strict')\n .trim()\n .replace(/ /g, '_');\n }\n\n function _cleanVal(text) {\n var clean = JSON.stringify(text)\n .replace(/\\\"/g, ' ')\n .replace(/\\'/g, ' ')\n .trim()\n .replace(/\\./g, '\\\\.')\n .replace(/\\-/g, '\\\\-')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\/g, '\\\\>')\n .replace(/\\\\n/g, '');\n\n if (clean.length > 42) {\n return clean.substring(0, 42) + '...';\n } else {\n return clean;\n }\n }\n\n // COMPUTATION\n\n switch (diagramType) {\n case 'graph':\n\n // create node\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Nodes') !== -1) {\n modelNames.push(modelName);\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = ' + modelName + '\\n\\t]';\n }\n }\n\n // create relationships\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n parents = this.require('factory').getParents(modelName);\n modelDef = this.require('factory').getGeneratedModel(modelName);\n if (modelName !== 'Nodes' && modelName !== 'Relationships' && parents.indexOf('Relationships') !== -1) {\n incoming = modelDef.incoming.type;\n outgoing = modelDef.outgoing.type;\n\n edges += `\\n\\tedge [\n headlabel = \"\"\n taillabel = \"\"\n fontsize = 5\n label = ${modelName}\n ]`;\n\n switch (true) {\n case incoming === 'Nodes' && outgoing === 'Nodes':\n modelNames.forEach(function (incoming) {\n modelNames.forEach(function (outgoing) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n });\n break;\n case incoming === 'Nodes' && outgoing !== 'Nodes':\n modelNames.forEach(function (incoming) {\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n });\n break;\n case incoming !== 'Nodes' && outgoing !== 'Nodes':\n edges += '\\n\\t' + _cleanName(incoming) + ' -> ' + _cleanName(outgoing) + '\\n';\n break;\n default:\n break;\n }\n }\n }\n\n break;\n\n case 'component':\n\n // create instances\n for (modelName in components) {\n schemaDef = this.require('factory').getGeneratedSchema(modelName);\n parents = this.require('factory').getParents(modelName);\n\n for (componentId in components[modelName]) {\n \n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n } else {\n instances += '\\n\\n\\t' + _cleanName(componentId) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + componentId + ' : ' + modelName + '|';\n }\n attributes = '';\n \n keys = [];\n sortedKeys = {};\n \n // get keys\n for (propName in components[modelName][componentId]) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = components[modelName][componentId][key];\n }.bind(this));\n\n for (var prop in sortedKeys) {\n if (prop !== '_id') {\n if (prop !== 'incoming' && prop !== 'outgoing') {\n if (schemaDef[prop] && schemaDef[prop] === 'collection') {\n if (sortedKeys[prop].length > 0) {\n attributes += '\\n\\t\\t\\t' + prop + ' = [\\\\l' + sortedKeys[prop].map(function(item) { return _cleanVal(item)}).join(',\\\\l') + '\\\\l]\\\\l'; \n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = []\\\\l'; \n }\n } else {\n attributes += '\\n\\t\\t\\t' + prop + ' = ' + _cleanVal(sortedKeys[prop]) + '\\\\l';\n }\n }\n \n if (schemaDef[prop] && (schemaDef[prop] === 'link' || schemaDef[prop] === 'collection')) {\n if (sortedKeys[prop] !== '') {\n \n switch(prop) {\n case 'incoming':\n relationships += '\\n\\t' + _cleanName(sortedKeys[prop]) + ' -> ' + _cleanName(componentId); \n break;\n case 'outgoing':\n relationships += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(sortedKeys[prop]); \n break;\n default:\n if (Array.isArray(sortedKeys[prop])) {\n sortedKeys[prop].forEach(function(item) {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(item); \n })\n } else {\n dependencies += '\\n\\t' + _cleanName(componentId) + ' -> ' + _cleanName(JSON.stringify(sortedKeys[prop]));\n }\n break;\n }\n }\n }\n }\n }\n\n if (modelName === 'Relationships' || parents.indexOf('Relationships') !== -1) {\n instancesRelation += attributes;\n instancesRelation += '\\n\\t\\t}\"\\r\\t]';\n } else {\n instances += attributes;\n instances += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n }\n break;\n\n case 'class':\n\n // create model for types\n for (typeId in types) {\n\n // structure\n if (types[typeId].schema) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + typeName + '|';\n\n attributes = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in types[typeId].schema) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = types[typeId].schema[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (types[typeId].schema.hasOwnProperty(propName)) {\n propDef = types[typeId].schema[propName];\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propDef.type + '\\\\l';\n if (_isType(propDef.type)) {\n dependencies += '\\n\\t' + _cleanName(typeName) + ' -> ' + propDef.type;\n }\n }\n }\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // enumeration\n if (types[typeId].value) {\n typeName = types[typeId].name;\n modelDescription += '\\n\\n\\t' + _cleanName(typeName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t\\\\<\\\\\\\\>\\\\l' + typeName + '|';\n\n attributes = '';\n\n types[typeId].value.forEach(function (enumValue) {\n attributes += '\\n\\t\\t\\t' + enumValue + '\\\\l';\n });\n\n modelDescription += _clean(attributes);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n }\n\n // create model\n for (modelId in models) {\n\n modelName = models[modelId]._name;\n modelDescription += '\\n\\n\\t' + _cleanName(modelName) + ' [\\n\\t\\tlabel = \"{\\n\\t\\t\\t' + modelName + '|';\n\n attributes = '';\n methods = '';\n keys = [];\n sortedKeys = {};\n\n // get keys\n for (propName in models[modelId]) {\n keys.push(propName);\n }\n keys.sort();\n\n // sorted keys\n keys.forEach(function (key) {\n sortedKeys[key] = models[modelId][key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n if (models[modelId].hasOwnProperty(propName)) {\n propVal = models[modelId][propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n\n links += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"1\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`\n links += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type;\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n //links += '\\n\\t' + modelName + ' -> ' + propVal.type;\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type + '\\\\l';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n\n if (modelId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (modelId !== '123751cb591de26') {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n dependencies += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0];\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n\n collections += `\\n\\tedge [\n arrowhead = \"${propVal.kind ? kindToEdgeStyle[propVal.kind] : 'none'}\"\n headlabel = \"0..*\"\n taillabel = \"\"\n label = \"${propVal.description ? propVal.description : ''}\"\n style = \"${propVal.kind === 'dependency' ? 'dashed' : 'normal'}\"\n ]`;\n\n collections += '\\n\\t' + _cleanName(modelName) + ' -> ' + propVal.type[0] + '\\n';\n }\n } else {\n attributes += '\\n\\t\\t\\t+ ' + propName + ' : ' + propVal.type[0] + ' [ ]\\\\l';\n //collections += '\\n\\t' + modelName + ' -> ' + propVal.type[0];\n // do not show types as links\n }\n }\n }\n break;\n\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + ' : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + params + '\\\\l';\n }\n }\n break;\n\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '() : ' + result + '\\\\l';\n }\n } else {\n if (modelId !== '123751cb591de26') {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n } else {\n methods += '\\n\\t\\t\\t+ ' + propName + '()\\\\l';\n }\n }\n break;\n }\n }\n }\n\n modelDescription += _clean(attributes) + '|' + _clean(methods);\n modelDescription += '\\n\\t\\t}\"\\r\\t]';\n }\n\n // create inheritance links\n for (var schema in schemas) {\n if (schemas[schema]._inherit && schemas[schema]._inherit.length) {\n schemas[schema]._inherit.forEach(function (parent) {\n inheritance += '\\n\\t' + _cleanName(schemas[schema]._name) + ' -> ' + parent;\n });\n }\n }\n\n // case of Component\n if (inheritance.indexOf('_Component') !== -1) {\n modelDescription += `\\n\\n\\t_Component [\n label = \"{\\n\\t\\t\\t_Component|\\n\\t\\t\\t+ id : string\\\\l|\\n\\t\\t\\t+ classInfo() : _ClassInfo\\\\l\\n\\t\\t\\t+ destroy()\\\\l\\n\\t\\t\\t+ error(data : errorParam)\\\\l\\n\\t\\t\\t+ init(conf : object)\\\\l\\n\\t\\t\\t+ off(state : string, behaviorId : string)\\\\l\\n\\t\\t\\t+ on(state : string, action : function, useCoreAPI : boolean, isCore : boolean) : string\\\\l\\n\\t\\t\\t+ require(id : string) : _Component\\\\l\\n\\t\\t}\"\n ]`\n };\n break;\n\n default:\n break;\n }\n\n // DIAGRAM\n \n switch (diagramType) {\n case 'graph':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n rankdir = LR\n size = 8\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"circle\"\n ]\n ${modelDescription}\n ${edges}\n}`;\n break;\n\n case 'component':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n ${instances}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n style = \"rounded\"\n ]\n ${instancesRelation}\n \n edge [\n arrowhead = \"none\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${relationships}\n}`;\n break;\n\n case 'class':\n generatedDiagram = `digraph system {\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n\n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n shape = \"record\"\n ]\n \n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]${modelDescription}\n \n node [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n ]\n ${instances}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${dependencies}\n \n edge [\n arrowhead = \"vee\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"dashed\"\n ]\n ${instancesOf}\n \n ${links}\n ${collections}\n edge [\n fontname = \"Bitstream Vera Sans\"\n fontsize = 10\n arrowhead = \"empty\"\n headlabel = \"\"\n taillabel = \"\"\n label = \"\"\n style = \"normal\"\n ]\n ${inheritance}\n}`;\n break;\n\n default:\n break;\n }\n\n return generatedDiagram;\n}","useCoreAPI":false,"core":false},"1c2e3132fd18c75":{"_id":"1c2e3132fd18c75","component":"Github","state":"refresh","action":"function refresh() {\n var config = {},\n gh = null,\n userName = '',\n repository = '';\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n repo = gh.getRepo(userName, repository);\n\n repo.getContents('master', '', 'raw')\n .then(function (contents) {\n contents.data.forEach(function (item) {\n if (item.type === 'file' && item.name.indexOf('.json') !== -1) {\n repo.getContents('master', item.name, 'raw')\n .then(function (content) {\n var system = content.data,\n systems = runtime.require('storage').get('system-designer-systems'),\n sys = null,\n sysStorage = null;\n\n // check valid system\n if (\n (Object.keys(system).indexOf('schemas') !== -1) &&\n (Object.keys(system).indexOf('models') !== -1) &&\n (Object.keys(system).indexOf('behaviors') !== -1) &&\n (Object.keys(system).indexOf('types') !== -1) &&\n (Object.keys(system).indexOf('components') !== -1)\n ) {\n\n delete system.classInfo;\n\n if (runtime.require('storage').get(system._id)) {\n runtime.require('github').merge(system);;\n } else {\n runtime.require('storage').set(system._id, system);\n }\n\n // save index\n if (!systems) {\n systems = { 'systems': [system._id] };\n } else {\n if (systems.systems.indexOf(system._id) === -1) {\n systems.systems.push(system._id);\n }\n }\n runtime.require('storage').set('system-designer-systems', systems);\n\n // refresh\n if (!runtime.require('factory').system()) {\n sys = runtime.require('factory').create(system);\n runtime.require('state').space(sys.name());\n }\n\n runtime.require('spaces').render();\n runtime.require('workspace').render();\n runtime.require('router').update();\n\n runtime.require('designer').save();\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n });\n\n if (contents.data.length === 0) {\n runtime.require('message').info('there is no system in your repository.');\n } else {\n runtime.require('message').success('Pull request finished with success.');\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"11845140101e5ae":{"_id":"11845140101e5ae","component":"Github","state":"push","action":"function push(comment, createHTML, createNode, logLevel, createPackage) {\n var config = {},\n gh = null,\n userName = '',\n repository = '',\n designer = null,\n system = {},\n repo1 = null,\n repo2 = null,\n repo3 = null;\n\n config = this.require('storage').get('system-designer-config');\n if (config && config.githubToken && config.githubRepository) {\n\n gh = new GitHub({\n token: atob(config.githubToken)\n });\n\n userName = config.githubRepository.split('/')[0];\n repository = config.githubRepository.split('/')[1];\n\n designer = this.require('designer');\n\n if (this.require('factory').system()) {\n system = this.require('db').collections().System.find({\n '_id': this.require('factory').system().id()\n })[0];\n\n system = JSON.parse(JSON.stringify(system));\n delete system.classInfo;\n\n repo1 = gh.getRepo(userName, repository);\n repo2 = gh.getRepo(userName, repository);\n repo3 = gh.getRepo(userName, repository);\n repo4 = gh.getRepo(userName, repository);\n \n var generatedId = Math.random() * 100000000000000000;\n var tempParam = '?_temp=' + generatedId;\n\n repo1.writeFile('master', system.name + '.json' + tempParam, JSON.stringify(system), comment || 'updated with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name.replace('.json', '');\n var js = '';\n var htmlSource = '';\n var jsSource = '';\n var packageSource = {};\n\n runtime.require('message').success('system ' + name + ' pushed on GitHub.');\n\n // HTML\n if (createHTML) {\n htmlSource = runtime.require('export-app-github.html').source();\n htmlSource = htmlSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo2.writeFile('master', runtime.require('factory').system().name() + '.html' + tempParam, htmlSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // Node\n if (createNode) {\n jsSource = runtime.require('app-github.js').source();\n jsSource = jsSource\n .replace(/{{logLevel}}/g, logLevel)\n .replace(/{{description}}/g, runtime.require('factory').system().description().replace(/\\n/g, '\\n * '))\n .replace(/{{version}}/g, runtime.require('factory').system().version())\n .replace(/{{name}}/g, runtime.require('factory').system().name());\n\n repo3.writeFile('master', runtime.require('factory').system().name() + '.js' + tempParam, jsSource, 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n\n // PACKAGE\n if (createPackage) {\n packageSource.name = runtime.require('factory').system().name();\n packageSource.version = runtime.require('factory').system().version();\n packageSource.description = runtime.require('factory').system().description();\n packageSource.main = './' + runtime.require('factory').system().name() + '.json';\n packageSource.repository = {};\n packageSource.repository.type = 'git';\n packageSource.repository.url = 'https://github.com/' + config.githubRepository;\n packageSource.dependencies = {};\n packageSource.dependencies['system-runtime'] = '^3.1.1';\n\n repo4.writeFile('master', 'package.json' + tempParam, JSON.stringify(packageSource, null, ' ').toString(), 'created with System Designer', {})\n .then(function (response) {\n var name = response.data.content.name;\n runtime.require('message').success(name + ' created on GitHub.');\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n }\n })\n .catch(function (e) {\n runtime.require('message').danger('GitHub: ' + e.response.data.message + '.');\n });\n } else {\n runtime.require('message').warning('There is no system to push on GitHub.');\n }\n } else {\n runtime.require('message').warning('No configuration found for GitHub. Please set the correct information in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"y194b01571d100d9":{"_id":"y194b01571d100d9","component":"Github","state":"merge","action":"function merge(sys) {\n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n designer = this.require('designer'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.require('storage').get(sys._id),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models) {\n if (system.models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas) {\n if (system.schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }/* else {\n result = false;\n }*/ // case of behavior on components\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n\n // schemas\n schemas = JSON.parse(JSON.stringify(system.schemas));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n system.schemas = schemas;\n\n // models\n models = JSON.parse(JSON.stringify(system.models));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n system.models = models;\n\n // types\n types = JSON.parse(JSON.stringify(system.types));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n system.types = types;\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(system.behaviors));\n for (name in sys.behaviors) {\n if (sys.behaviors[name].component === sys._id || _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n }\n }\n system.behaviors = behaviors;\n\n // components\n components = JSON.parse(JSON.stringify(system.components));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n\n system.schemas = schemas;\n system.models = models;\n system.types = types;\n system.behaviors = behaviors;\n system.components = components;\n\n system.version = sys.version;\n system.description = sys.description;\n\n this.require('storage').set(sys._id, system);\n if (this.require('factory').system().id() === system._id) {\n this.require('factory').create(system);\n }\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to merge is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c103c31cc9d1821e":{"_id":"c103c31cc9d1821e","component":"HTML","state":"render","action":"function render(id) { \n var dom = null;\n \n id = id || 'designer-workspace';\n \n if (id === 'body') {\n dom = document.body;\n } else {\n dom = document.getElementById(id);\n }\n \n dom.insertAdjacentHTML('beforeend', this.getHTML());\n}","useCoreAPI":false,"core":false},"e5ef68c9-d858-4ac2-8eea-82580d0f29df":{"_id":"e5ef68c9-d858-4ac2-8eea-82580d0f29df","component":"HTML","state":"getHTML","action":"function getHTML() { \n var html = this.source();\n var pattern = '';\n var matches = null;\n var message = '';\n var key = '';\n \n // localization\n pattern = //;\n matches = html.match(pattern);\n\n if (matches) {\n \n key = matches[0].split('{')[1].split('}')[0].trim();\n message = this.require('i18n').get(key);\n \n html = html.replace(matches[0], message);\n }\n \n return html;\n}","useCoreAPI":false,"core":false},"f71c2810-ffb7-4f19-a94b-2e08ec78d256":{"_id":"f71c2810-ffb7-4f19-a94b-2e08ec78d256","component":"Internationalization","state":"get","action":"function get(key) { \n let strings = this.require(this.locale());\n if (!strings) {\n strings = this.require('en-US');\n }\n return strings[key]();\n}","useCoreAPI":false,"core":false},"e1e35e1690f16945":{"_id":"e1e35e1690f16945","component":"Language","state":"createBehaviorBody","action":"function createBehaviorBody(returnedType) { \n\tvar body = ' \\n';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n switch (returnedType) {\n case 'css':\n case 'html':\n case 'javascript': \n case 'string':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'array':\n body = \" let result = [];\\n return result;\\n\";\n break;\n case 'number':\n body = \" let result = 0;\\n return result;\\n\";\n break;\n case 'boolean':\n body = \" let result = false;\\n return result;\\n\";\n break;\n case 'object':\n case 'json':\n body = \" let result = {};\\n return result;\\n\";\n break;\n case 'date':\n body = \" let result = '';\\n return result;\\n\";\n break;\n case 'any':\n body = \" let result = '';\\n return result;\\n\";\n break;\n default:\n body = \" let result = {};\\n return result;\\n\";\n break;\n }\n\t break;\n\t default:\n\t break;\n\t}\n\t\n\treturn body;\n}","useCoreAPI":false,"core":false},"v19a5a1998c1efa2":{"_id":"v19a5a1998c1efa2","component":"Language","state":"createBehavior","action":"function createBehavior(name, params, body) { \n\tvar behavior = '',\n\t funcName = '';\n\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (body === '') {\n\t body = ' \\n';\n\t }\n\t \n\t if (name.indexOf('.') !== -1) {\n\t funcName = name.split('.')[name.split('.').length - 1];\n\t } else {\n\t funcName = name;\n\t }\n\t \n\t behavior = \"function \" + funcName + \"(\" + params + \") { \\n\" + body + \"}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"v1825c1731e17082":{"_id":"v1825c1731e17082","component":"Language","state":"createDestroyBehavior","action":"function createDestroyBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function destroy() { \\n\\n // destroy the component\\n $component.destroy(this.id());\\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"z138a2168e11cfc5":{"_id":"z138a2168e11cfc5","component":"Language","state":"createStartBehavior","action":"function createStartBehavior() { \n\tvar behavior = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t behavior = \"function start() { \\n \\n}\";\n\t break;\n default:\n break;\n\t}\n\t\n\treturn behavior;\n}","useCoreAPI":false,"core":false},"a17ad5184f61b5cd":{"_id":"a17ad5184f61b5cd","component":"Language","state":"createMergeComment","action":"function createMergeComment(systemName) { \n\tvar comment = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t comment = '\\n // from system ' + systemName + '\\n';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn comment;\n}","useCoreAPI":false,"core":false},"s1bb671c9261461a":{"_id":"s1bb671c9261461a","component":"Language","state":"createBehaviorHeader","action":"function createBehaviorHeader(name, params) { \n\tvar header = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t header = 'function ' + name + '(' + params + ') ';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn header;\n}","useCoreAPI":false,"core":false},"x1833b1fece19d5b":{"_id":"x1833b1fece19d5b","component":"Language","state":"createBehaviorParameters","action":"function createBehaviorParameters(model) { \n\tvar params = '',\n\t i = 0,\n\t length = 0;\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t if (model && model.length) {\n length = model.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = model[i].name;\n } else {\n params = params + ', ' + model[i].name;\n }\n }\n }\n\t break;\n default:\n break;\n\t}\n\t\n\treturn params;\n}","useCoreAPI":false,"core":false},"l171be17d531662a":{"_id":"l171be17d531662a","component":"Language","state":"createBehaviorParametersEvent","action":"function createBehaviorParametersEvent() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"y16ae91b06c1a586":{"_id":"y16ae91b06c1a586","component":"Language","state":"createBehaviorParametersEventArray","action":"function createBehaviorParametersEventArray() { \n\tvar parameters = '';\n\t\n\tswitch(this.target()) {\n\t case 'javascript':\n\t parameters = 'value, type';\n\t break;\n default:\n break;\n\t}\n\t\n\treturn parameters;\n}","useCoreAPI":false,"core":false},"b126ff129e914cfa":{"_id":"b126ff129e914cfa","component":"MenuBar","state":"render","action":"function render() {\n var length = 0,\n i = 0,\n item = null,\n domHeader = document.getElementById('designer-menubar-header'),\n domItems = document.getElementById('designer-menubar-items'),\n domAction = document.getElementById('designer-menubar-actions'),\n self = this,\n arr = window.location.href.split('#'),\n params = window.location.href.split('?messages='),\n messages = [],\n context = 'systems',\n space = '',\n designer = this.require('designer'),\n menuHeader = [],\n menuItems = [],\n menuActions = [],\n menuSearch = [];\n config = {},\n isModeAdvanced = false,\n platform = '',\n platformMenuItems = [];\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n }\n \n // empty\n $('#designer-menubar-header').empty();\n $('#designer-menubar-items').empty();\n $('#designer-menubar-actions').empty();\n this.items([]);\n this.actions([]);\n \n // get mode \n config = this.require('storage').get('system-designer-config');\n if (config && config.advancedMode) {\n isModeAdvanced = true;\n }\n\n // menu header\n menuHeader = this.require('db').collections().MenuHeader.find({\n 'type': this.require('state').type()\n });\n this.header(this.require(menuHeader[0]._id));\n\n // menu items\n menuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch(true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformMenuItems = this.require('db').collections().MenuItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n menuItems = menuItems.concat(platformMenuItems);\n\n menuItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n menuItems.forEach(function (menuItem) {\n var id = menuItem._id;\n var name = menuItem.name;\n \n if ((name === 'bundle' && self.require('state').type() === 'system') || (name === 'behavior' && self.require('state').type() === 'behavior')) {\n if (isModeAdvanced) {\n self.items().push(self.require(id));\n }\n } else {\n self.items().push(self.require(id));\n }\n });\n\n // menu actions\n menuActions = this.require('db').collections().MenuAction.find({\n 'type': this.require('state').type()\n }).sort({\n 'position': 1\n });\n\n menuActions.forEach(function (menuAction) {\n var id = menuAction._id;\n self.actions().push(self.require(id));\n });\n\n // header\n domHeader.insertAdjacentHTML('afterbegin', this.header().html().source());\n\n // items\n this.require('state').navigation().menu([]);\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n this.require('state').navigation().menu().push('designer-menu-item-' + item.name());\n }.bind(this));\n\n // events\n var callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.items(i)));\n }\n\n // actions\n this.actions().forEach(function (action) {\n domAction.insertAdjacentHTML('beforeend', '
  • ' + action.html().source() + '');\n });\n\n length = domAction.children.length;\n for (i = 0; i < length; i++) {\n item = domAction.children[i];\n item.addEventListener('click', function click() {\n this.click();\n }.bind(self.actions(i)));\n }\n\n if (this.require('state').type() === 'designer') {\n // focus on first element\n // or restore the context\n if (arr.length > 2 && arr[2].length !== 0) {\n context = arr[2];\n context = context.split('?')[0];\n }\n if (arr.length > 3) {\n space = arr[3];\n space = space.split('?')[0];\n }\n if (arr.length > 4) {\n this.require('state').component(arr[4].split('?')[0]);\n }\n \n length = this.items().length;\n for (i = 0; i < length; i++) {\n if (this.items(i).name() === context) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n if (space) {\n this.require('state').space(decodeURIComponent(space));\n }\n this.require('state').menu(context);\n\n this.require('router').update();\n\n // run messages\n if (params[1]) {\n messages = JSON.parse(decodeURIComponent(params[1]));\n if (runtime.require('factory').system() && runtime.require('factory').system().name() !== 'default') {\n this.require('state').messages(messages);\n }\n }\n } else {\n // focus on first element\n if (length > 0) {\n this.require('state').menu(this.items(0).name());\n item = domItems.children[0];\n $(item).addClass('active');\n }\n }\n \n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"f1c1eb158101aab8":{"_id":"f1c1eb158101aab8","component":"Message","state":"clean","action":"function clean() {\n document.querySelector('#designer-message').innerHTML = '';\n}"},"f1bf2a100901b407":{"_id":"f1bf2a100901b407","component":"Message","state":"danger","action":"function danger(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-danger.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-danger-' + id;\n \n this.clean(); \n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"i1b72d17c6c154ab":{"_id":"i1b72d17c6c154ab","component":"Message","state":"info","action":"function info(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-info.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-info-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"s1a2461e9b9155cc":{"_id":"s1a2461e9b9155cc","component":"Message","state":"success","action":"function success(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-success.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-success-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"k1dd3c148c011f25":{"_id":"k1dd3c148c011f25","component":"Message","state":"warning","action":"function warning(message) {\n var id = requestAnimationFrame(function () {\n var html = this.require('message-alert-warning.html').source(),\n id = this.require('factory').generateId(),\n domId = 'designer-message-warning-' + id;\n \n this.clean();\n \n message = message.replace('[object Object]', 'message can not be displayed because it is not a string.');\n \n document.querySelector('#designer-message').insertAdjacentHTML('afterbegin', \n html.replace(/{{message}}/gi, message)\n .replace(/{id}/gi, id)\n );\n $('#' + domId).fadeIn(500);\n \n setTimeout(function () {\n $('#' + domId).fadeOut(1000, function() {\n $(this).remove();\n });\n }, 4000);\n }.bind(this));\n \n setTimeout(function () {\n cancelAnimationFrame(id);\n }, 50);\n}"},"l17e9c1fb07156c0":{"_id":"l17e9c1fb07156c0","component":"ModelSystem","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '';\n\n // html \n html = this.require('model-system.html');\n\n for (propName in this.document()) {\n if (['name', 'description', 'version'].indexOf(propName) !== -1) {\n propVal = this.document()[propName];\n propVal = propVal.replace(/\\n/g, '
    ');\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-system-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('system.html#' + that.uuid() + '#description', that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-system-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the system?

    The related schemas, models, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var systems = this.require('storage').get('system-designer-systems'),\n designer = this.require('designer'),\n state = this.require('state'),\n System = this.require('System'),\n systemId = this.data().uuid,\n that = this,\n isUninstalled = false;\n \n function _isExtensionInstalled (id) {\n var extensions = that.require('db').collections().Extension.find({\n 'installed':true\n }),\n result = false;\n \n extensions.forEach(function (val) {\n if (val.source._id === id) {\n result = true;\n }\n });\n \n return result;\n } \n \n // uninstall extension\n if (this.require('factory').system().name().indexOf('extension-') !== -1) {\n // check if installed as Extensions\n if (!_isExtensionInstalled(this.require('factory').system().id())) {\n if (this.require('ext_' + this.require('factory').system().id())) {\n this.require('runtime').stop('ext_' + this.require('factory').system().id());\n \t this.require('runtime').uninstall('ext_' + this.require('factory').system().id());\n \t this.require('menubar').render();\n \t this.require('toolbar').render();\n \t \n \t isUninstalled = true;\n }\n }\n } \n\n // remove from storage\n this.require('storage').remove(systemId);\n systems.systems.splice(systems.systems.indexOf(systemId), 1);\n this.require('storage').set('system-designer-systems', systems);\n \n this.require('factory').system().destroy();\n \n // remove log\n state.logs([]);\n \n // hide log if any\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n // set default system\n if (systems.systems.length) {\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n \n $('#designer-system-' + this.data().uuid).remove();\n this.require(this.data().ui).destroy();\n \n designer.require('state').space('');\n \n designer.require('spaces').render();\n designer.require('workspace').render();\n \n this.hide();\n \n if (isUninstalled) {\n this.require('message').success('The system has been deleted and the related extension has been uninstalled.');\n } else {\n this.require('message').success('The system has been deleted.');\n }\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"y1d4ef15995101f1":{"_id":"y1d4ef15995101f1","component":"ModelSystem","state":"hide","action":"function hide() { \n $('#designer-system-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s1f1d11cc651c54c":{"_id":"s1f1d11cc651c54c","component":"ModelSystem","state":"show","action":"function show() { \n $('#designer-system-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"h14f82133531cb01":{"_id":"h14f82133531cb01","component":"ModelType","state":"render","action":"function render() {\n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n propDescription = '',\n systemId = '',\n keys = [];\n sortedKeys = {};\n\n systemId = this.require('factory').system().id();\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n\n function _getLink(propName, val, description) {\n var result = '';\n\n if (!Array.isArray(val)) {\n if (that.require('factory').isModel(val)) {\n if (val !== '_Component') {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val) === -1) {\n result = '
    ' + propName + '' + val + '
    ';\n } else {\n result = '
    ' + propName + val + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(val[0])) {\n if (val[0] !== '_Component') {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(val[0]) === -1) {\n result = '
    ' + propName + '' + val[0] + ' [ ]
    ';\n } else {\n result = '
    ' + propName + val[0] + ' [ ]
    ';\n }\n }\n }\n\n return result;\n }\n\n // html \n html = this.require('model-type.html');\n\n if (this.document().schema) {\n \n // get keys\n for (propName in this.document().schema) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document().schema[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().schema.hasOwnProperty(propName)) {\n propVal = this.document().schema[propName].type;\n propDescription = this.document().schema[propName].description;\n doc = doc + _getLink(propName + ' : ', propVal, propDescription);\n }\n }\n }\n\n if (this.document().value) {\n this.document().value.sort().forEach(function (val) {\n doc = doc + '
    ' + val + '
    ';\n });\n }\n\n\n if (!this.document().schema && !this.document().value) {\n propVal = this.document().type;\n doc = doc + '
    alias : ' + propVal + '
    ';\n }\n\n if (doc === '') {\n doc = doc + '

    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, this.uuid())\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-type-' + this.uuid()).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('type.html#' + that.uuid() + '#' + systemId, that.uuid());\n\n // force hide tooltip\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n }.bind(this));\n }\n\n html = document.getElementById('designer-type-' + this.uuid() + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete'),\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the type?'\n });\n\n data = dialog.data();\n\n data.ui = this.id();\n data.uuid = this.uuid();\n data.title = this.title();\n\n dialog.data(data);\n\n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n types = this.require('factory').system().types();\n\n delete types[this.data().title];\n this.require('factory').system().types(types);\n\n $('#designer-type-' + this.data().title).remove();\n\n this.require('channel').$designerDeleteType(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render();\n\n this.hide();\n this.require('message').success('The type has been deleted.');\n });\n\n dialog.show();\n }.bind(this));\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"y193ad1d2dd19a94":{"_id":"y193ad1d2dd19a94","component":"ModelType","state":"hide","action":"function hide() { \n $('#designer-type-' + this.title()).hide();\n}","useCoreAPI":false,"core":false},"r1fddf1076313f2a":{"_id":"r1fddf1076313f2a","component":"ModelType","state":"show","action":"function show() { \n $('#designer-type-' + this.title()).show();\n}","useCoreAPI":false,"core":false},"x1ef931bdf218b5c":{"_id":"x1ef931bdf218b5c","component":"ModelSchema","state":"render","action":"function render() { \n var html = null,\n doc = '',\n that = this,\n propName = '',\n propVal = '',\n htmlId = '',\n keys = [],\n sortedKeys = {};\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n // html \n html = this.require('model-schema.html');\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (this.document().hasOwnProperty(propName) && propName.indexOf('_') !== 0) {\n propVal = this.document()[propName];\n doc = doc + '' + propName + '' + propVal + '';\n }\n }\n\n if (doc === '') {\n doc = doc + '





    ';\n }\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{id}}/gi, htmlId)\n .replace(/{{content}}/gi, doc)\n );\n\n //events\n if (this.editable()) {\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('schema.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-schema-' + htmlId + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the schema?

    The related model, behaviors and components will be also deleted.'\n });\n \n data = dialog.data();\n \n data.ui = this.id();\n data.uuid = this.uuid();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var designer = this.require('designer');\n\n this.require('factory').deleteSchema(this.data().uuid);\n\n $('#designer-schema-' + this.data().uuid).remove();\n\n this.require('channel').$designerDeleteSchema(this.data().uuid);\n\n this.require(this.data().ui).destroy();\n\n jsPlumb.deleteEveryEndpoint();\n\n designer.save();\n\n designer.require('state').space('');\n designer.require('spaces').render();\n designer.require('workspace').render(); \n \n this.hide();\n this.require('message').success('The schema, the related model, behaviors and components have been deleted.');\n });\n \n dialog.show(); \n \n }.bind(this));\n }\n } else {\n $('#designer-schema-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-schema-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().schemas()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#schemas#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component schema'\n });\n DialogComponentInfo.show();\n }\n }.bind(this));\n }\n }\n}","useCoreAPI":false,"core":false},"s16bee11b7711ffc":{"_id":"s16bee11b7711ffc","component":"ModelSchema","state":"hide","action":"function hide() { \n $('#designer-schema-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"s129cc1a59c1d6e0":{"_id":"s129cc1a59c1d6e0","component":"ModelSchema","state":"show","action":"function show() { \n $('#designer-schema-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"d1cc401928b148ce":{"_id":"d1cc401928b148ce","component":"ModelClass","state":"render","action":"function render() {\n var html = null,\n that = this,\n propName = '',\n attributes = '',\n collections = '',\n methods = '',\n events = '',\n propVal = '',\n result = '',\n callbackProp = null,\n htmlId = '',\n htmlComp = null,\n systemId = '',\n keys = [],\n sortedKeys = {},\n length = 0,\n i = 0;\n\n htmlId = this.uuid() || this.title();\n systemId = this.require('factory').system().id();\n\n callbackProp = function (param) {\n var realType = param.type;\n var isArray = false;\n\n if (Array.isArray(param.type)) {\n isArray = true;\n realType = param.type[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component') {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '' + '], ';\n } else {\n params = params + param.name + ' : ' + realType + '' + ', ';\n }\n } else {\n if (isArray) {\n params = params + param.name + ' : [' + realType + '], ';\n } else {\n params = params + param.name + ' : ' + realType + ', ';\n }\n }\n }\n };\n\n function _getReturnType(returnType) {\n var result = '';\n var realType = returnType;\n var isArray = false;\n\n if (Array.isArray(returnType)) {\n isArray = true;\n realType = returnType[0];\n }\n\n if (that.require('factory').isModel(realType) && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'errorParam', 'json', 'text', 'date'].indexOf(realType) === -1 && realType !== '_Component' && realType !== '_ClassInfo') {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = '' + realType + '';\n }\n } else {\n if (isArray) {\n result = '[' + realType + ']';\n } else {\n result = realType;\n }\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.require('factory').system().models()) {\n if (that.require('factory').system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _setTitle(description) {\n var result = '';\n\n if (description) {\n result = ' data-toggle=\"tooltip\" data-placement=\"right\" title=\"' + description + '\"';\n }\n return result;\n }\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n\n for (propName in sortedKeys) {\n //if (this.document().hasOwnProperty(propName)) {\n propVal = this.document()[propName];\n\n switch (true) {\n case typeof propVal.type !== 'undefined':\n if (!Array.isArray(propVal.type)) {\n if (that.require('factory').isModel(propVal.type)) {\n if (htmlId !== '123751cb591de26' && propVal.type !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type + '
    ';\n }\n }\n } else {\n if (that.require('factory').isModel(propVal.type[0])) {\n if (htmlId !== '123751cb591de26' && propVal.type[0] !== '_Component') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n if (['any', 'boolean', 'string', 'number', 'object', 'function', 'array', 'html', 'javascript', 'css', 'json', 'text', 'date'].indexOf(propVal.type[0]) === -1) {\n if (htmlId !== '123751cb591de26') {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n } else {\n attributes = attributes + '
    + ' + propName + ' : ' + propVal.type[0] + ' [ ]
    ';\n }\n }\n }\n break;\n case typeof propVal.params !== 'undefined':\n result = 'undefined';\n var params = '(';\n propVal.params.forEach(callbackProp.bind(this));\n params = params + ')';\n params = params.replace(', )', ')');\n\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + ' : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + ' : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '' + params + '
    ';\n } else {\n methods = methods + '
    + ' + propName + params + '
    ';\n }\n }\n break;\n case propName.indexOf('_') !== -1:\n // we do not show private / internal properties\n break;\n default:\n result = 'undefined';\n if (typeof propVal.result !== 'undefined') {\n result = _getReturnType(propVal.result);\n\n if (htmlId !== '123751cb591de26') {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n } else {\n methods = methods + '
    + ' + propName + '() : ' + result + '
    ';\n }\n } else {\n if (htmlId !== '123751cb591de26') {\n methods = methods + '';\n } else {\n methods = methods + '
    + ' + propName + '()
    ';\n }\n }\n break;\n }\n //\"\"}\n }\n\n if (attributes === '') {\n attributes = attributes + '
    ';\n }\n if (methods === '') {\n methods = methods + '
    ';\n }\n\n // html \n htmlComp = this.require('model-class.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, htmlId)\n .replace(/{{attributes}}/gi, attributes)\n .replace(/{{collections}}/gi, collections)\n .replace(/{{methods}}/gi, methods)\n .replace(/{{events}}/gi, events)\n );\n\n // events\n if (this.editable()) {\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('model.html#' + that.uuid() + '#' + systemId, that.uuid());\n }.bind(this));\n }\n } else {\n $('#designer-model-' + htmlId + ' > div > div > div > button').hide();\n\n html = document.getElementById('designer-model-' + htmlId).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n var DialogComponentInfo = null;\n\n if (this.title() !== '_Component') {\n if (this.require('factory').system().models()[that.uuid()]) {\n this.require('designer').open('index.html#' + this.require('factory').system().id() + '#models#' + that.uuid(), '_self');\n } else {\n this.require('message').warning('Your schema \\‘' + that.title() + '\\’ has not been yet created.');\n }\n } else {\n DialogComponentInfo = this.require('DialogComponentInfo');\n DialogComponentInfo = new DialogComponentInfo({\n 'title': '_Component model'\n });\n DialogComponentInfo.show();\n\n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n }\n }.bind(this));\n }\n }\n\n $(function () {\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"e1b783124781eb46":{"_id":"e1b783124781eb46","component":"ModelClass","state":"hide","action":"function hide() { \n $('#designer-class-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"e1860d16c061bd75":{"_id":"e1860d16c061bd75","component":"ModelClass","state":"show","action":"function show() { \n $('#designer-class-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"a10e171013c1a0a3":{"_id":"a10e171013c1a0a3","component":"ModelBehavior","state":"render","action":"function render() { \n var template = '',\n html = null,\n that = this,\n systemId = '';\n\n systemId = this.require('factory').system().id();\n\n // html \n template = this.require('model-behavior.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n template.source()\n .replace(/{{_id}}/gi, this.uuid())\n .replace(/{{title}}/gi, this.title())\n .replace(/{{content}}/gi, this.content().replace(/' + id + ',
    ';\n }\n \n systemId = this.require('factory').system().id();\n schema = this.require('factory').getGeneratedSchema(this.model());\n model = this.require('factory').getGeneratedModel(this.model());\n components = this.require('factory').system().components();\n \n // get keys\n for (propName in this.document()) {\n keys.push(propName);\n }\n keys.sort();\n \n // sorted keys\n keys.forEach(function(key) {\n sortedKeys[key] = this.document()[key];\n }.bind(this));\n \n for (propName in sortedKeys) {\n if (sortedKeys.hasOwnProperty(propName) && propName !== '_id' && propName !== '_core') {\n propVal = sortedKeys[propName];\n value = JSON.stringify(propVal);\n\n switch (true) {\n case schema[propName] === 'link':\n if (typeof propVal === 'string') {\n modelName = model[propName].type;\n \n if (components && components[modelName] && components[modelName][sortedKeys[propName]]) {\n // component found\n } else {\n realModelName = _getModelFromComponent(sortedKeys[propName]);\n if (realModelName) {\n modelName = realModelName;\n }\n }\n\n doc = doc + '' + propName + '' + propVal + '';\n } else {\n doc = doc + '' + propName + '' + value + '';\n }\n break;\n case schema[propName] === 'collection':\n if (Array.isArray(propVal) && this.require('factory').isModel(model[propName].type[0])) {\n propVal.forEach(_createLink);\n doc = doc + '' + propName + '[' + links + ']';\n doc = doc.replace(',
    ]', ']');\n } else {\n if (value.length < 25) {\n doc = doc + '' + propName + '' + value + '';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 25) + ' ...';\n }\n }\n break;\n default:\n if (value.length < 25) {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.replace(/';\n } else {\n doc = doc + '' + propName + '' + value.replace(/';\n }\n } else {\n if (typeof propVal === 'string') {\n doc = doc + '' + propName + '' + propVal.substring(0, 23).replace(/';\n } else {\n doc = doc + '' + propName + '' + value.substring(0, 23).replace(/';\n }\n }\n break;\n }\n }\n }\n\n if (doc === '') {\n doc = doc + '



    ';\n }\n\n // html \n htmlComp = this.require('model-component.html');\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{_id}}/gi, this.uuid().replace(/\\./g, '-'))\n .replace(/{{content}}/gi, doc)\n );\n\n // events\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-')).children[0].children[1];\n if (html) {\n html.addEventListener('click', function click(event) {\n this.require('designer').open('component.html#' + encodeURIComponent(that.title()) + '#' + encodeURIComponent(that.model()) + '#' + systemId, that.uuid());\n }.bind(this));\n }\n\n html = document.getElementById('designer-component-' + this.uuid().replace(/\\./g, '-') + '-delete');\n if (html) {\n html.addEventListener('click', function click(event) {\n var Dialog = this.require('DialogDelete')\n data = {},\n dialog = {};\n\n dialog = new Dialog({\n 'title': 'Confirm deletion',\n 'message': 'Do you want to delete the component?'\n });\n \n data = dialog.data();\n \n data.model = this.model();\n data.uuid = this.uuid();\n data.ui = this.id();\n \n dialog.data(data);\n \n dialog.on('ok', function ok() {\n var uuid = this.data().uuid,\n model = this.data().model,\n ui = this.data().ui;\n \n this.require('factory').deleteComponent(uuid, model);\n \n $('#designer-component-' + uuid.replace(/\\./g, '-')).fadeOut(400, function fadeOut() {\n $(this).remove();\n \n if ($('#designer-workspace').children().length === 0) {\n runtime.require('message-help').render();\n }\n });\n \n this.require('channel').$designerDeleteComponent(uuid, model);\n this.hide();\n \n this.require(ui).destroy();\n \n this.require('designer').save();\n this.require('message').success('The component has been deleted.');\n });\n \n dialog.show();\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"s1320a140a91efd8":{"_id":"s1320a140a91efd8","component":"ModelComponent","state":"hide","action":"function hide() { \n $('#designer-component-' + this.uuid()).hide();\n}","useCoreAPI":false,"core":false},"l107d01de7f1f8b0":{"_id":"l107d01de7f1f8b0","component":"ModelComponent","state":"show","action":"function show() { \n $('#designer-component-' + this.uuid()).show();\n}","useCoreAPI":false,"core":false},"l102fa1aac8159a8":{"_id":"l102fa1aac8159a8","component":"ModelLog","state":"render","action":"function render() { \n var html = null,\n that = this,\n doc = '',\n propName = '',\n propVal = '',\n logs = '';\n\n // html \n htmlComp = this.require('model-log.html');\n\n // logs\n this.require('state').logs().forEach(function (log) {\n var filter = this.require('state').space();\n \n switch (log.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n logs = logs + '

    ' + log.log() + '

    ';\n }\n break;\n default:\n break;\n }\n }.bind(this));\n\n document.querySelector('#designer-workspace').insertAdjacentHTML('afterbegin',\n htmlComp.source().replace('{{logs}}', logs)\n );\n\n // events \n html = document.getElementById('designer-log-clean');\n\n html.addEventListener('click', function click(event) {\n this.require('state').logs([]);\n document.querySelector('#designer-loug-output').innerHTML = '';\n this.require('message').success('The logs have been cleared.');\n }.bind(this));\n}","useCoreAPI":false,"core":false},"c19c981365a18e6f":{"_id":"c19c981365a18e6f","component":"ModelLog","state":"hide","action":"function hide() { \n $('#designer-log').hide();\n}","useCoreAPI":false,"core":false},"f182891664d151ab":{"_id":"f182891664d151ab","component":"ModelLog","state":"show","action":"function show() { \n $('#designer-log').show();\n}","useCoreAPI":false,"core":false},"d1a56d197331e510":{"_id":"d1a56d197331e510","component":"SystemFactory","state":"mergeBehavior","action":"function mergeBehavior(behaviors, behavior, sysId, systemName) { \n\tvar that = this,\n\t source = {},\n\t lastA = -1,\n\t firstB = -1,\n\t lastB = -1,\n\t toAdd = '';\n\t \n\tfunction _getBehavior() {\n\t var result = null,\n\t id = '';\n\t \n\t for (id in behaviors) {\n\t if (behaviors[id].state === behavior.state && behaviors[id].component === sysId) {\n\t result = behaviors[id];\n\t break;\n\t }\n\t }\n\t \n\t if (!result) {\n\t result = {\n\t \"_id\": that.generateId(),\n\t \"component\": sysId,\n\t \"state\": behavior.state,\n\t \"action\": that.require('language').createBehavior(behavior.state),\n\t };\n\t }\n\t \n\t return result;\n\t} \n\t\n\tsource = _getBehavior();\n\t \n\tlastA = source.action.lastIndexOf('}');\n\tfirstB = behavior.action.indexOf('{');\n\tlastB = behavior.action.lastIndexOf('}');\n\t\n\ttoAdd = behavior.action.substring(firstB + 1, lastB);\n\t\n\tif (toAdd.trim() !== '') { \n\t toAdd = this.require('language').createMergeComment(systemName) + toAdd + '\\n}';\n\t} else {\n\t toAdd = '}';\n\t}\n\t\n\tsource.action = source.action.substring(0, lastA) + toAdd;\n\t\n\tbehaviors[source._id] = source;\n}","useCoreAPI":false,"core":false},"r177551fafb195af":{"_id":"r177551fafb195af","component":"SystemFactory","state":"getGeneratedSchema","action":"function getGeneratedSchema(schema) { \n var schemaDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = 'init';\n result.destroy = 'destroy';\n result.error = 'error';\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(schema, this.system().schemas());\n\n for (propName in schemaDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = schemaDef[propName];\n }\n }\n\n if (schemaDef._inherit) {\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n\n return result;\n}","useCoreAPI":false,"core":false},"z13a3b1308218a5d":{"_id":"z13a3b1308218a5d","component":"SystemFactory","state":"getGeneratedModel","action":"function getGeneratedModel(model) { \n var modelDef = null,\n result = {},\n i = 0,\n length = 0,\n propName = '';\n\n function _getInherit(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id]._inherit;\n break;\n }\n }\n return result;\n }\n\n function _getModelDef(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = models[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, models, schemas) {\n var parent = '',\n modelDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.init = {\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n };\n\n result.destroy = {\n \"params\": []\n };\n\n result.error = {\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n };\n\n } else {\n modelDef = _getModelDef(parent, models);\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0 && typeof result[propName] === 'undefined') {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(parent, schemas)) {\n _searchParents(_getInherit(parent, schemas), result, models, schemas);\n }\n }\n }\n }\n\n modelDef = _getModelDef(model, this.system().models());\n\n for (propName in modelDef) {\n if (propName.indexOf('_') !== 0) {\n result[propName] = modelDef[propName];\n }\n }\n\n if (_getInherit(model, this.system().schemas())) {\n try {\n _searchParents(_getInherit(model, this.system().schemas()), result, this.system().models(), this.system().schemas());\n } catch(e) {\n this.require('message').danger('You have a cyclic inheritance problem with your current schema, please update your schema.');\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"z13676132a318174":{"_id":"z13676132a318174","component":"SystemFactory","state":"generateId","action":"function generateId() {\n // taken from https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n function gen() {\n return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n\n // force the uuid to start with a letter\n function genPrefix() {\n var validPrefix = 'abcdef';\n return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));\n }\n \n return genPrefix() + gen();\n}","useCoreAPI":false,"core":false},"f14ed91a7d21b111":{"_id":"f14ed91a7d21b111","component":"SystemFactory","state":"syncBehavior","action":"function syncBehavior(model) { \n var behaviors = this.system().behaviors(),\n components = this.system().components(),\n schema = null,\n propName = '',\n params = '',\n header = '',\n def = null,\n methodDef = null,\n length = 0,\n i = 0,\n behaviorId = '',\n action = '',\n behavior = null,\n that = this;\n\n function _getSchema(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = that.system().schemas()[id];\n break;\n }\n }\n return result;\n }\n\n schema = _getSchema(model._name);\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'method':\n case schema[propName] === 'event':\n // params\n def = model[propName];\n\n if (typeof model[propName] !== 'object') {\n if (schema[propName] === 'method') {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ],\n \"result\": \"string\"\n };\n } else {\n def = {\n \"params\": [\n {\n \"name\": \"param\",\n \"type\": \"string\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n ]\n };\n }\n }\n methodDef = def.params;\n params = '';\n if (methodDef && methodDef.length) {\n length = methodDef.length;\n for (i = 0; i < length; i++) {\n if (i === 0) {\n params = methodDef[i].name;\n } else {\n params = params + ', ' + methodDef[i].name;\n }\n }\n }\n\n header = this.require('language').createBehaviorHeader(propName, params);\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n \n // behaviors on models\n if (behavior.component === model._name && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n \n // behaviors on components\n for (var component in components[model._name]) {\n if (behavior.component === components[model._name][component]._id && behavior.state === propName) {\n action = behavior.action.split('{');\n action[0] = header;\n behaviors[behaviorId].action = action.join('{');\n this.system().behaviors(behaviors);\n this.require('channel').$designerUpdateBehavior(behavior._id, behavior);\n }\n }\n }\n\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"y17ae11cbc214f76":{"_id":"y17ae11cbc214f76","component":"SystemFactory","state":"syncModel","action":"function syncModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n behaviors = this.system().behaviors(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null,\n createModel = false;\n\n name = schema._name;\n\n // search\n for (id in models) {\n if (models[id]._name === schema._name) {\n model = models[id];\n }\n }\n\n // case of no model\n if (!model) {\n createModel = true;\n model = {\n \"_id\": this.generateId(),\n \"_name\": name,\n \"_description\": \"\",\n };\n }\n\n // previous schema\n oldSchema = schemas[schema._id];\n for (propName in schema) {\n if ((schema.hasOwnProperty(propName) &&\n oldSchema &&\n (typeof oldSchema[propName] === 'undefined' ||\n oldSchema[propName] !== schema[propName])) ||\n createModel\n ) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case schema[propName] === 'method':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n // create behavior\n this.createBehavior('method', model._name, propName, model[propName]);\n }\n\n break;\n case schema[propName] === 'event':\n if (typeof model[propName] === 'undefined' || (typeof model[propName] !== 'undefined' && typeof model[propName].type !== 'undefined')) {\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n // remove this to create a behavior by default for event\n //this.createBehavior('event', model._name, propName, model[propName]);\n } else {\n if (typeof model[propName].result !== 'undefined') {\n delete model[propName].result;\n }\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n break;\n case propName.indexOf('_') !== 1:\n if (propName !== '_id' && propName !== '_inherit') {\n model[propName] = schema[propName];\n }\n break;\n default:\n break;\n }\n }\n }\n\n if (oldSchema) {\n for (propName in oldSchema) {\n if (propName.indexOf('_') !== 0 && typeof schema[propName] === 'undefined') {\n delete model[propName];\n\n for (component in components[name]) {\n delete components[name][component][propName];\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n\n for (behavior in behaviors) {\n if (model && behaviors[behavior].component === model._name && behaviors[behavior].state === propName) {\n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n for (component in components[name]) {\n if (behaviors[behavior] && behaviors[behavior].component === components[name][component]._id && behaviors[behavior].state === propName) { \n delete behaviors[behavior];\n this.require('channel').$designerDeleteBehavior(behavior);\n this.system().behaviors(behaviors);\n }\n }\n }\n }\n }\n }\n\n models[model._id] = model;\n this.system().models(models);\n this.require('channel').$designerUpdateModel(model._id, model);\n}","useCoreAPI":false,"core":false},"z16b03119e81c817":{"_id":"z16b03119e81c817","component":"SystemFactory","state":"syncComponent","action":"function syncComponent(model, oldModel, forceDelete) { \n var components = this.system().components(),\n name = '',\n componentId = '',\n propName = '',\n modelDef = null,\n component = null,\n createModel = false;\n\n name = model._name;\n\n schema = this.getGeneratedSchema(name);\n modelDef = this.getGeneratedModel(name);\n \n function isEqual(arrA, arrB) {\n var result = true;\n var strA = '';\n var strB = '';\n \n try {\n strA = JSON.stringify(arrA);\n strB = JSON.stringify(arrB);\n \n result = strA === strB;\n } catch(e) {\n result = false;\n }\n \n return result;\n }\n\n for (propName in schema) {\n switch (true) {\n case schema[propName] === 'property':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'link':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (modelDef[propName].type !== oldModel[propName].type) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n modelDef[propName].type === oldModel[propName].type && \n modelDef[propName].default !== oldModel[propName].default &&\n components[name][component][propName] === oldModel[propName].default\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n case schema[propName] === 'collection':\n for (component in components[name]) {\n if (typeof components[name][component][propName] === 'undefined') {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n } else {\n if (oldModel && oldModel[propName]) {\n // update type => update component value\n if (!isEqual(modelDef[propName].type, oldModel[propName].type)) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n // update default value => update component value\n if (\n isEqual(modelDef[propName].type, oldModel[propName].type) && \n !isEqual(modelDef[propName].default, oldModel[propName].default) &&\n isEqual(components[name][component][propName], oldModel[propName].default)\n ) {\n components[name][component][propName] = modelDef[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n this.system().components(components);\n }\n }\n }\n }\n break;\n default:\n break;\n }\n }\n\n if (forceDelete) {\n for (componentId in components[name]) {\n for (propName in components[name][componentId]) {\n if (typeof modelDef[propName] === 'undefined' && propName.indexOf('_') !== 0) {\n delete components[name][componentId][propName];\n this.require('channel').$designerDeleteComponent(componentId, name);\n this.system().components(components);\n }\n }\n }\n }\n}","useCoreAPI":false,"core":false},"f17e231c64613693":{"_id":"f17e231c64613693","component":"SystemFactory","state":"createModel","action":"function createModel(schema) { \n var schemas = this.system().schemas(),\n models = this.system().models(),\n components = this.system().components(),\n name = '',\n id = '',\n propName = '',\n component = null,\n behavior = null,\n model = null,\n oldSchema = null;\n\n id = this.generateId();\n\n model = {\n \"_id\": id,\n \"_name\": schema._name,\n \"_description\": \"\"\n };\n\n for (propName in schema) {\n if (propName.indexOf('_') !== 0) {\n switch (true) {\n case schema[propName] === 'property':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"any\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'link':\n model[propName] = {\n \"description\": \"\",\n \"type\": \"_Component\",\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": \"\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'method':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }],\n \"result\": \"any\"\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'event':\n model[propName] = {\n \"description\": \"\",\n \"params\": [{\n \"description\": \"\",\n \"name\": \"param\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": null\n }]\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n case schema[propName] === 'collection':\n model[propName] = {\n \"description\": \"\",\n \"type\": [\"_Component\"],\n \"kind\": \"normal\",\n \"readOnly\": false,\n \"mandatory\": false,\n \"default\": []\n };\n\n for (component in components[name]) {\n components[name][component][propName] = model[propName].default;\n this.require('channel').$designerUpdateComponent(component, name, components[name][component]);\n }\n\n break;\n default:\n break;\n }\n }\n }\n\n models[id] = model;\n\n this.system().models(models);\n \n this.require('channel').$designerCreateModel(model._id, model);\n this.system().components(components);\n \n return model;\n}","useCoreAPI":false,"core":false},"z1168215afe1773c":{"_id":"z1168215afe1773c","component":"SystemFactory","state":"deleteSchema","action":"function deleteSchema(id, sync) {\n var behaviorId = '',\n modelId = '',\n behavior = null,\n schemas = this.system().schemas(),\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n schemaName = '';\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (sync && schemas[id] && schemas[id]._name) {\n \n schemaName = schemas[id]._name;\n \n // components\n delete components[schemaName];\n this.system().components(components);\n \n // behaviors\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === schemaName) {\n delete behaviors[behaviorId];\n this.system().behaviors(behaviors);\n }\n }\n \n // model\n modelId = _getModelId(schemas[id]._name, models);\n if (modelId) {\n delete models[modelId];\n this.system().models(models);\n }\n }\n\n // schema\n delete schemas[id];\n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1bc5010b18187ff":{"_id":"v1bc5010b18187ff","component":"SystemFactory","state":"createBehavior","action":"function createBehavior(type, model, state, def) { \n var body = '\\t\\n',\n behaviors = this.system().behaviors();\n\n function _canCreate(type, component, state, behaviors) {\n var behavior = {},\n id = '',\n exist = false,\n result = true;\n\n for (id in behaviors) {\n behavior = behaviors[id];\n if (behavior.component === component && behavior.state === state) {\n exist = true;\n break;\n }\n }\n if (exist) {\n result = false;\n }\n\n return result;\n }\n\n if (_canCreate(type, model, state, behaviors)) {\n uuid = this.generateId();\n\n // params\n methodDef = def.params;\n params = this.require('language').createBehaviorParameters(methodDef);\n\n // body\n result = def.result;\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n\n // set behavior\n behavior = {\n \"_id\": uuid,\n \"component\": model,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n\n behaviors[uuid] = behavior;\n\n this.system().behaviors(behaviors);\n\n this.require('channel').$designerCreateBehavior(behavior);\n }\n}","useCoreAPI":false,"core":false},"c1b62f1086818a0f":{"_id":"c1b62f1086818a0f","component":"SystemFactory","state":"mergeSystem","action":"function mergeSystem(sys) { \n var System = this.require('System'),\n name = '',\n propName = '',\n modelName = '',\n compId = '',\n modelId = '',\n schemaId = '',\n factory = this.require('factory'),\n schemas = {},\n models = {},\n types = {},\n components = {},\n behaviors = {},\n system = this.system(),\n message = this.require('message');\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().models()) {\n if (factory.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in factory.system().schemas()) {\n if (factory.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _canOverrideBehavior(id, component, state, behaviors) {\n var behavior = {},\n behaviorId = '';\n\n for (behaviorId in behaviors) {\n behavior = behaviors[behaviorId];\n if (behavior.component === component && behavior.state === state && behavior._id !== id) {\n delete behaviors[behavior._id];\n break;\n }\n }\n }\n\n function _canOverride(sysId, schemas, behaviors, behavior) {\n var def = {},\n id = '',\n result = true;\n\n id = _getSchemaId(behavior.component);\n def = schemas[id];\n\n if (def && def[behavior.state]) {\n if (def[behavior.state] === 'method') {\n _canOverrideBehavior(behavior._id, behavior.component, behavior.state, behaviors);\n }\n }\n\n if ((behavior.state === 'error' || behavior.state === 'start' || behavior.state === 'stop') && behavior.component === sysId) {\n result = false;\n }\n\n return result;\n }\n\n if (Object.keys(sys).length) {\n \n // schemas\n schemas = JSON.parse(JSON.stringify(this.require('factory').system().schemas()));\n for (name in sys.schemas) {\n if (schemas[name]) {\n for (propName in sys.schemas[name]) {\n schemas[name][propName] = sys.schemas[name][propName];\n }\n } else {\n if (!_getSchemaId(sys.schemas[name]._name)) {\n schemas[name] = sys.schemas[name];\n } else {\n for (propName in sys.schemas[name]) {\n if (propName.indexOf('_') !== 0) {\n schemas[_getSchemaId(sys.schemas[name]._name)][propName] = sys.schemas[name][propName];\n }\n }\n }\n }\n }\n this.require('factory').system().schemas(schemas);\n\n // behaviors\n behaviors = JSON.parse(JSON.stringify(this.require('factory').system().behaviors()));\n for (name in sys.behaviors) {\n if (name !== sys._id && _canOverride(sys._id, schemas, behaviors, sys.behaviors[name])) {\n behaviors[name] = sys.behaviors[name];\n } else {\n // merge error / start / stop\n if ((sys.behaviors[name].state === 'error' || sys.behaviors[name].state === 'start' || sys.behaviors[name].state === 'stop') && sys.behaviors[name].component === sys._id) {\n this.require('factory').mergeBehavior(behaviors, sys.behaviors[name], this.require('factory').system().id(), sys.name);\n }\n }\n }\n this.require('factory').system().behaviors(behaviors);\n\n\n // models\n models = JSON.parse(JSON.stringify(this.require('factory').system().models()));\n for (name in sys.models) {\n if (models[name]) {\n for (propName in sys.models[name]) {\n models[name][propName] = sys.models[name][propName];\n }\n } else {\n if (!_getModelId(sys.models[name]._name)) {\n models[name] = sys.models[name];\n } else {\n for (propName in sys.models[name]) {\n if (propName.indexOf('_') !== 0) {\n models[_getModelId(sys.models[name]._name)][propName] = sys.models[name][propName];\n }\n }\n }\n }\n }\n \n // sync models\n for (schemaId in schemas) {\n this.require('factory').syncModel(schemas[schemaId]);\n }\n \n this.require('factory').system().models(models);\n\n // sync behaviors and components\n for (modelId in models) {\n this.require('factory').syncBehavior(models[modelId]);\n }\n\n // types\n types = JSON.parse(JSON.stringify(this.require('factory').system().types()));\n for (name in sys.types) {\n if (types[name]) {\n for (propName in sys.types[name]) {\n types[name][propName] = sys.types[name][propName];\n }\n } else {\n types[name] = sys.types[name];\n }\n }\n this.require('factory').system().types(types);\n\n // components\n components = JSON.parse(JSON.stringify(this.require('factory').system().components()));\n for (modelName in sys.components) {\n if (!components[modelName]) {\n components[modelName] = {};\n }\n for (compId in sys.components[modelName]) {\n if (components[modelName][compId]) {\n for (propName in sys.components[modelName][compId]) {\n components[modelName][compId][propName] = sys.components[modelName][compId][propName];\n }\n } else {\n components[modelName][compId] = sys.components[modelName][compId];\n }\n }\n }\n this.require('factory').system().components(components);\n\n // sync components\n for (modelId in models) {\n this.require('factory').syncComponent(models[modelId]);\n }\n\n this.require('factory').system().schemas(schemas);\n this.require('factory').system().models(models);\n this.require('factory').system().types(types);\n this.require('factory').system().behaviors(behaviors);\n this.require('factory').system().components(components);\n\n if (this.require('factory').system().id() === sys._id) {\n this.require('factory').system().version(sys.version);\n this.require('factory').system().description(sys.description);\n }\n\n message.success('Composition of the system is done.');\n } else {\n if (this.require('factory').system()) {\n message.danger('The system you try to import is invalid.');\n } else {\n message.danger('There is no system to compose with.');\n }\n }\n}","useCoreAPI":false,"core":false},"c179f91426817730":{"_id":"c179f91426817730","component":"SystemFactory","state":"updateBehavior","action":"function updateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"p1bf7312724172d3":{"_id":"p1bf7312724172d3","component":"SystemFactory","state":"updateComponent","action":"function updateComponent(id, collection, field, value) { \n var components = this.system().components();\n var subField = field.split('.');\n var length = subField.length;\n var i = 0;\n var arr = '';\n var index = -1;\n var component = null;\n\n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined' && \n typeof components[collection][id] !== 'undefined') {\n \n if (components[collection][id][subField[0]] !== 'undefined') {\n component = components[collection][id];\n \n for (i = 0; i < length - 1; i++) {\n if (subField[i].indexOf('[') !== -1) {\n arr = subField[i].split('[')[0];\n index = subField[i].split('[')[1].replace(']', '');\n component = component[arr][index];\n } else {\n component = component[subField[i]];\n }\n }\n component[subField[i]] = value;\n \n this.system().components(components);\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"u15b121620519864":{"_id":"u15b121620519864","component":"SystemFactory","state":"deleteComponent","action":"function deleteComponent(id, collection) { \n var components = this.system().components(),\n behaviors = this.system().behaviors(),\n behaviorId = '';\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] !== 'undefined') {\n delete components[collection][id];\n this.system().components(components);\n \n // remove behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === id) {\n \t this.deleteBehavior(behaviorId);\n \t this.require('channel').$designerDeleteBehavior(behaviorId);\n \t break;\n \t }\n }\n }\t\n }\n}","useCoreAPI":false,"core":false},"d129be15b711107c":{"_id":"d129be15b711107c","component":"SystemFactory","state":"createComponent","action":"function createComponent(collection, component) { \n var components = this.system().components();\n \n function _hasSchema(name, schemas) {\n var result = false,\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = true;\n break;\n }\n }\n return result;\n }\n \n if (_hasSchema(collection, this.system().schemas())) {\n if (typeof components[collection] === 'undefined') {\n components[collection] = {};\n }\n \n delete component.classInfo;\n \n components[collection][component._id] = component;\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"x10f461f9731db3d":{"_id":"x10f461f9731db3d","component":"SystemFactory","state":"updateSystem","action":"function updateSystem(id, system) { \n var System = this.require('System'),\n sys = null;\n\n if (this.system()) {\n this.system().destroy();\n }\n \n sys = new System(system);\n this.system(sys);\n}","useCoreAPI":false,"core":false},"b1c3581800519d9b":{"_id":"b1c3581800519d9b","component":"SystemFactory","state":"overwriteComponent","action":"function overwriteComponent(id, collection, component) { \n var components = this.system().components();\n \n components[collection][id] = component;\n this.system().components(components);\n}","useCoreAPI":false,"core":false},"p1258b190941d225":{"_id":"p1258b190941d225","component":"SystemFactory","state":"deleteBehavior","action":"function deleteBehavior(id) { \n var behaviors = this.system().behaviors();\n\n delete behaviors[id];\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"n199891dd69109ed":{"_id":"n199891dd69109ed","component":"SystemFactory","state":"udpdateBehavior","action":"function udpdateBehavior(id, behavior) { \n var behaviors = this.system().behaviors();\n\n behaviors[id] = behavior;\n this.system().behaviors(behaviors);\n}","useCoreAPI":false,"core":false},"s15ad71a52019253":{"_id":"s15ad71a52019253","component":"SystemFactory","state":"updateModelId","action":"function updateModelId(oldId, newId) { \n var models = this.system().models(),\n model = null;\n\n model = JSON.parse(JSON.stringify(models[oldId]));\n\n delete models[oldId];\n\n model._id = newId;\n models[newId] = model;\n\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"a1ae681430b1cbc0":{"_id":"a1ae681430b1cbc0","component":"SystemFactory","state":"updateModel","action":"function updateModel(id, model) { \n var models = this.system().models();\n \n models[id] = model;\n this.system().models(models);\n}","useCoreAPI":false,"core":false},"p17e2e1c19b19ed7":{"_id":"p17e2e1c19b19ed7","component":"SystemFactory","state":"updateSchemaId","action":"function updateSchemaId(oldId, newId) { \n var schemas = this.system().schemas(),\n schema = null;\n\n schema = JSON.parse(JSON.stringify(schemas[oldId]));\n\n delete schemas[oldId];\n\n schema._id = newId;\n \n schemas[newId] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"o188e9105da13288":{"_id":"o188e9105da13288","component":"SystemFactory","state":"updateSchema","action":"function updateSchema(id, schema) { \n var schemas = this.system().schemas();\n \n schemas[id] = schema;\n \n this.system().schemas(schemas);\n}","useCoreAPI":false,"core":false},"v1fc521228d1d589":{"_id":"v1fc521228d1d589","component":"SystemFactory","state":"updateSchemaName","action":"function updateSchemaName(name, id) { \n var oldName = this.system().schemas()[id]._name,\n models = this.system().models(),\n behaviors = this.system().behaviors(),\n components = this.system().components(),\n modelId = '',\n behaviorId = '',\n behavior = null;\n\n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(oldName, this.system().models());\n\n // update model\n models[modelId]._name = name;\n this.system().models(models);\n\n // update behaviors\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldName) {\n behaviors[behaviorId].component = name;\n\n this.system().behaviors(behaviors);\n }\n }\n\n // components\n if (components[oldName]) {\n components[name] = JSON.parse(JSON.stringify(components[oldName]));\n delete components[oldName];\n\n this.system().components(components);\n }\n}","useCoreAPI":false,"core":false},"o1a54f1f354126b9":{"_id":"o1a54f1f354126b9","component":"SystemFactory","state":"deleteType","action":"function deleteType(id) { \n var types = this.system().types();\n\n delete types[id];\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g151cb1f2bc16ab5":{"_id":"g151cb1f2bc16ab5","component":"SystemFactory","state":"updateType","action":"function updateType(id, type) { \n var types = this.system().types();\n\n types[id] = type;\n this.system().types(types);\n}","useCoreAPI":false,"core":false},"g172411b1b817aec":{"_id":"g172411b1b817aec","component":"SystemFactory","state":"create","action":"function create(sys, withStartMethod) { \n var System = this.require('System'),\n uuid = this.generateId(),\n mainUuid = this.generateId(),\n system = {},\n instance = null,\n migrateSys = '';\n \n sys = JSON.parse(JSON.stringify(sys)); \n \n // deprecated property\n // delete sys.subsystem;\n \n // migrate v1->v2\n // migrateSys = JSON.stringify(sys);\n // migrateSys = migrateSys.replace(/\\\"RuntimeComponent\\\"/g, '\"_Component\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeDatabase\\\"/g, '\"_Database\"');\n // migrateSys = migrateSys.replace(/\\\"RuntimeChannel\\\"/g, '\"_Channel\"');\n // migrateSys = migrateSys.replace(/\\\"\\u0040/g, '\"');\n \n // sys = JSON.parse(migrateSys);\n \n \n // default system\n system = {\n \"name\": \"default\",\n \"master\": true,\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"schemas\": {},\n \"models\": {},\n \"behaviors\": {},\n \"types\": {},\n \"components\": {},\n \"_id\": uuid\n };\n \n for (var prop in sys) {\n if (sys.hasOwnProperty(prop)) {\n system[prop] = sys[prop];\n }\n }\n\n if (withStartMethod) {\n // add main method\n system.behaviors[mainUuid] = {\n \"_id\": mainUuid,\n \"component\": system._id,\n \"state\": \"start\",\n \"action\": this.require('language').createStartBehavior(),\n \"useCoreAPI\": false,\n \"core\": false\n };\n }\n\n // add (TODO improve)\n if (this.system()) {\n this.system().destroy();\n }\n \n instance = new System(system);\n\n this.system(instance);\n\n return instance;\n}","useCoreAPI":false,"core":false},"j18c34108721d01d":{"_id":"j18c34108721d01d","component":"SystemFactory","state":"toJSON","action":"function toJSON() { \n var result = {};\n\t\n if (this.system()) {\n result = this.require('db').collections().System.find({\n '_id': this.system().id()\n })[0];\n }\n\t\n result = JSON.parse(JSON.stringify(result));\n delete result.classInfo;\n\t\n return result;\n}","useCoreAPI":false,"core":false},"f184d9169fd1d682":{"_id":"f184d9169fd1d682","component":"SystemFactory","state":"addSchema","action":"function addSchema(name) { \n var id = this.generateId().toString(),\n schema = {},\n schemas = {};\n \n // set schema\n schema = {\n \"_id\": id,\n \"_name\": name,\n \"_inherit\": [\"_Component\"]\n };\n \n schemas = this.system().schemas();\n schemas[id] = schema;\n \n this.system().schemas(schemas);\n \n return JSON.parse(JSON.stringify(schema));\n}","useCoreAPI":false,"core":false},"h16f101a2bf17a4d":{"_id":"h16f101a2bf17a4d","component":"SystemFactory","state":"addType","action":"function addType(name, isEnum) { \n var id = this.generateId().toString(),\n types = this.system().types(),\n type = {};\n \n // set type\n if (isEnum) {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"any\",\n \"value\": [\"value1\", \"value2\"]\n };\n } else {\n type = {\n \"_id\": id,\n \"name\": name,\n \"description\": \"\",\n \"type\": \"object\",\n \"schema\": {\n \"property1\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"property2\": {\n \"description\":\"\",\n \"type\": \"any\",\n \"mandatory\": false,\n \"default\": \"\"\n }\n }\n };\n }\n \n types[name] = type;\n this.require('factory').system().types(types);\n \n return JSON.parse(JSON.stringify(type));\n}","useCoreAPI":false,"core":false},"j18b1b101501aead":{"_id":"j18b1b101501aead","component":"SystemFactory","state":"addComponent","action":"function addComponent(model) { \n var schemaDef = this.getGeneratedSchema(model),\n components = this.system().components(),\n uuid = this.generateId(),\n component = {};\n \n // set component\n component = {\n \"_id\": uuid,\n };\n \n // set properties default values\n var propertyNames = [];\n for (var att in schemaDef) {\n if (schemaDef[att] === 'property') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'link') {\n propertyNames.push(att);\n }\n if (schemaDef[att] === 'collection') {\n propertyNames.push(att);\n }\n }\n \n propertyNames.sort();\n \n modelDef = this.getGeneratedModel(model);\n \n length = propertyNames.length;\n for (var i = 0; i < length; i++) {\n if (modelDef && modelDef[propertyNames[i]]) {\n component[propertyNames[i]] = modelDef[propertyNames[i]].default;\n }\n }\n \n if (!components[model]) {\n components[model] = {};\n }\n components[model][uuid] = component;\n \n this.system().components(components);\n \n return JSON.parse(JSON.stringify(component));\n}","useCoreAPI":false,"core":false},"w1c83110cfc1f1f9":{"_id":"w1c83110cfc1f1f9","component":"SystemFactory","state":"addBehavior","action":"function addBehavior(model, component, state) {\n var that = this,\n schemas = this.system().schemas(),\n models = this.system().models(),\n modelDef = null,\n factory = this,\n behaviors = this.system().behaviors(),\n types = this.system().types(),\n message = this.require('message'),\n language = this.require('language'),\n schemaId = '',\n modelId = '',\n methodDef = null,\n behavior = {},\n result = '',\n body = '\\t\\n',\n ModelBehavior = null,\n modelBehavior = null,\n uuid = '',\n params = '',\n canCreate = true,\n i = 0,\n length = 0,\n pathType = '';\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().schemas()) {\n if (that.system().schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _existBehavior(state, space, model) {\n var result = false;\n\n if (_isModel(space)) {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === model) {\n result = true;\n break;\n }\n }\n } else {\n for (id in that.system().behaviors()) {\n if (that.system().behaviors()[id].state === state && that.system().behaviors()[id].component === space) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n function _isModel(name) {\n var result = false;\n\n if (Object.keys(that.system().components()).indexOf(name) !== -1) {\n result = true;\n }\n\n return result;\n }\n\n // get value\n\n if (model && state) {\n\n uuid = this.require('factory').generateId();\n\n if (model !== this.require('factory').system().name()) {\n\n schemaId = _getSchemaId(model);\n modelId = _getModelId(model);\n modelDef = this.getGeneratedModel(model);\n\n // method params\n if (modelDef[state]) {\n methodDef = modelDef[state].params;\n }\n params = language.createBehaviorParameters(methodDef);\n \n \n // property params\n if (schemas[schemaId][state] === 'property' || schemas[schemaId][state] === 'link') {\n if (models[modelId][state].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure\n if (state.indexOf('.') !== -1) {\n pathType = this.getModelPathType(model, state);\n if (Array.isArray(pathType)) {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n /*if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'property' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }\n \n // case of structure in an array\n if (state.indexOf('.') !== -1 && schemas[schemaId][state.split('.')[0]] === 'collection' && typeof types[models[modelId][state.split('.')[0]].type] !== 'undefined') {\n if (types[models[modelId][state.split('.')[0]].type].schema[state.split('.')[1]].type === 'array') {\n params = language.createBehaviorParametersEventArray();\n } else {\n params = language.createBehaviorParametersEvent();\n }\n }*/\n \n // collection params\n if (schemas[schemaId][state] === 'collection') {\n params = language.createBehaviorParametersEventArray();\n }\n\n // method params\n if (schemas[schemaId][state] === 'method') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n \n // _Component state params\n if (state === 'init') {\n params = 'conf';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'destroy') {\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n if (state === 'error') {\n params = 'data';\n if (_existBehavior(state, this.require('state').space(), model)) {\n canCreate = false;\n }\n }\n\n // body\n if (modelDef[state]) {\n result = modelDef[state].result;\n }\n if (result) {\n body = this.require('language').createBehaviorBody(result);\n }\n } else {\n component = this.require('factory').system().id();\n \n if (state === 'error') {\n params = 'data';\n }\n \n if (_existBehavior(state, component, model)) {\n canCreate = false;\n }\n }\n\n if (canCreate) {\n // set model\n if (state !== 'destroy') {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": state,\n \"action\": this.require('language').createBehavior(state, params, body),\n \"useCoreAPI\": false,\n \"core\": false\n };\n } else {\n behavior = {\n \"_id\": uuid,\n \"component\": component,\n \"state\": \"destroy\",\n \"action\": this.require('language').createDestroyBehavior(),\n \"useCoreAPI\": true,\n \"core\": false\n };\n }\n\n behaviors[uuid] = behavior;\n this.require('factory').system().behaviors(behaviors);\n }\n }\n \n return JSON.parse(JSON.stringify(behavior));\n}","useCoreAPI":false,"core":false},"u1e3e81ddc719f7f":{"_id":"u1e3e81ddc719f7f","component":"SystemFactory","state":"updateComponentId","action":"function updateComponentId(oldId, newId, collection) { \n var behaviors = this.require('factory').system().behaviors(),\n behavior = {},\n behaviorId ='';\n\n this.updateComponent(oldId, collection, '_id', newId);\n // TODO ? this.require('channel').$designerUpdateComponent ...\n \n // update behaviors linked to the component\n for (behaviorId in behaviors) {\n if (behaviors[behaviorId].component === oldId) {\n behavior = behaviors[behaviorId];\n behavior.component = newId;\n this.updateBehavior(behaviorId, behavior);\n this.require('channel').$designerUpdateBehavior(behaviorId, behavior);\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"c104ab1e9711e87a":{"_id":"c104ab1e9711e87a","component":"SystemFactory","state":"getModelPaths","action":"function getModelPaths(model) { \n\tvar result = [],\n\t modelDef = '',\n\t components = this.system().components(),\n\t prop = '',\n\t propType = '',\n\t types = this.system().types();\n\t \n function _findModelName(id) {\n var result = id,\n modelName = '';\n \n for (modelName in components) {\n if (typeof components[modelName][id] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n } \n \n function _findPathRec(path, type) {\n if (typeof types[type] !== 'undefined' && typeof types[type].schema !== 'undefined') {\n for (propType in types[type].schema) {\n result.push(path + '.' + propType);\n \n _findPathRec(path + '.' + propType, types[type].schema[propType].type);\n }\n }\n }\n \n modelDef = this.getGeneratedModel(_findModelName(model));\n\t\n\tif (model !== this.system().name()) {\n \tfor (prop in modelDef) {\n \t if (modelDef[prop].type && typeof types[modelDef[prop].type] !== 'undefined') {\n \t if (typeof types[modelDef[prop].type].schema !== 'undefined') {\n \t result.push(prop);\n \t for (propType in types[modelDef[prop].type].schema) {\n \t result.push(prop + '.' + propType);\n \t \n \t _findPathRec(prop + '.' + propType, types[modelDef[prop].type].schema[propType].type);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n \t } else {\n \t result.push(prop);\n \t }\n }\n } else {\n result.push('error');\n result.push('start');\n result.push('stop');\n }\n\n result.sort();\n \n return result;\n}","useCoreAPI":false,"core":false},"d1915d138cc1d922":{"_id":"d1915d138cc1d922","component":"SystemFactory","state":"isModel","action":"function isModel(name) { \n\tvar schemas = this.system().schemas(),\n\t result = false,\n\t prop = '';\n\t \n\tif (name === '_Component') {\n\t result = true; \n\t}\n\t\n\tif (!result) {\n\t for (prop in schemas) {\n\t if (schemas[prop]._name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"l128b8102d81d2ac":{"_id":"l128b8102d81d2ac","component":"SystemFactory","state":"getModelPathType","action":"function getModelPathType(model, path) { \n var result = null;\n var subpaths = [];\n var subpath = '';\n var i = 0;\n var length = 0;\n var structure = '';\n var models = this.system().models();\n var modelId = '';\n var types = this.system().types();\n var that = this;\n \n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in that.system().models()) {\n if (that.system().models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n modelId = _getModelId(model);\n subpaths = path.split('.');\n length = subpaths.length;\n\n for (i = 0; i < length; i++) {\n subpath = subpaths[i];\n subpath = subpath.split('[')[0];\n if (i === 0) {\n result = models[modelId][subpath].type;\n } else {\n // collection\n if (Array.isArray(result)) {\n result = result[0];\n }\n // structure\n structure = types[result];\n if (structure && structure.schema) {\n result = structure.schema[subpath].type;\n }\n }\n }\n return result;\n}","useCoreAPI":false,"core":false},"v119e617ef513e94":{"_id":"v119e617ef513e94","component":"SystemFactory","state":"isType","action":"function isType(name) { \n var types = this.system().types(),\n result = false,\n prop = '';\n\n\tif (!result) {\n\t for (prop in types) {\n\t if (schemas[prop].name === name) {\n\t result = true;\n\t break;\n\t }\n\t }\n\t}\n\t\n\treturn result;\n}","useCoreAPI":false,"core":false},"p116a812b6310e26":{"_id":"p116a812b6310e26","component":"SystemFactory","state":"getParents","action":"function getParents(name) { \n var schemaDef = null,\n parent = '',\n tempResult = {};\n result = [];\n\n function _getSchemaDef(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = schemas[id];\n break;\n }\n }\n return result;\n }\n\n function _searchParents(parents, states, schemas) {\n var parent = '',\n schemaDef = null,\n i = 0,\n length = 0;\n\n length = parents.length;\n for (i = 0; i < length; i++) {\n parent = parents[i];\n if (parent === '_Component') {\n result.push('_Component');\n } else {\n schemaDef = _getSchemaDef(parent, schemas);\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, schemas);\n }\n }\n }\n }\n\n schemaDef = _getSchemaDef(name, this.system().schemas());\n\n if (schemaDef._inherit) {\n result = result.concat(schemaDef._inherit);\n _searchParents(schemaDef._inherit, result, this.system().schemas());\n }\n \n // clean\n result.forEach(function (parent) {\n tempResult[parent] = parent;\n });\n \n result = [];\n for (parent in tempResult) {\n result.push(parent);\n }\n \n return result;\n}","useCoreAPI":false,"core":false},"n12d44154da1020f":{"_id":"n12d44154da1020f","component":"ToolBar","state":"render","action":"function render() { \n var domItems = document.getElementById('designer-toolbar-items'),\n i = 0,\n length = 0,\n item = null,\n toolBarItems = [],\n platformToolBarItems = [],\n platform = '',\n self = this;\n \n // empty\n $('#designer-toolbar-items').empty();\n this.items([]);\n\n // get items\n toolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': 'all'\n });\n \n // get platform specific items\n switch (true) {\n case this.require('designer').isElectron() === true:\n platform = 'electron';\n break;\n case this.require('designer').isCordova() === true:\n platform = 'cordova';\n break;\n default:\n platform = 'web';\n break;\n }\n \n platformToolBarItems = this.require('db').collections().ToolBarItem.find({\n 'type': this.require('state').type(),\n 'platform': platform\n });\n \n toolBarItems = toolBarItems.concat(platformToolBarItems);\n\n // sort items\n toolBarItems.sort(function (itemA, itemB) {\n if (itemA.position > itemB.position) {\n return 1;\n }\n if (itemA.position < itemB.position) {\n return -1;\n }\n return 0;\n });\n\n toolBarItems.forEach(function (toolBarItem) {\n var id = toolBarItem._id;\n self.items().push(self.require(id));\n });\n\n // render items\n this.items().forEach(function (item) {\n domItems.insertAdjacentHTML('beforeend', '
  • ' + item.html().source() + '');\n });\n\n // add events\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n}","useCoreAPI":false,"core":false},"d1c07e16ad411943":{"_id":"d1c07e16ad411943","component":"MessageHelp","state":"render","action":"function render() {\n var template = '';\n var message = '';\n var dom = null;\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n\n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n\n template = this.require('message-help.html');\n\n switch (true) {\n case menu === 'systems':\n message = \"To create a system, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && hasSystem():\n message = \"To create a schema, click on the '+' button or click here.\";\n break;\n case menu === 'schemas' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'models' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'models' && hasSystem() && !hasSchema:\n message = \"To create a model, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'types' && hasSystem():\n message = \"To create a type, click on the '+' button or click here.\";\n break;\n case menu === 'types' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'behaviors' && hasSystem():\n message = \"To create a behavior, click on the '+' button or click here.\";\n break; \n case menu === 'behaviors' && !hasSystem():\n message = \"To create a system, click here.\";\n break; \n case menu === 'components' && hasSystem() && hasSchema:\n message = \"To create a component, click on the '+' button or click here.\";\n break;\n case menu === 'components' && hasSystem() && !hasSchema:\n message = \"To create a component, you need to create first a schema. Click here to create a schema.\";\n break;\n case menu === 'components' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'logs' && !hasSystem():\n message = \"To create a system, click here.\";\n break;\n case menu === 'class' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'component' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n case menu === 'graph' && !hasSystem():\n message = \"To view a diagram, create first a system or drag and drop a Graphviz file here.\";\n break;\n default:\n break;\n }\n\n if (menu === 'class' || menu === 'component' || menu === 'graph') {\n document.querySelector('#designer-diagram').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n } else {\n document.querySelector('#designer-workspace').insertAdjacentHTML(\n 'afterbegin',\n template.source().replace(/{{message}}/gi, message));\n }\n\n // events\n dom = document.getElementById('panel-message-help');\n if (dom && menu !== 'class' && menu !== 'component' && menu !== 'graph') {\n dom.addEventListener('click', function click(event) {\n var menu = this.require('state').menu();\n var system = this.require('factory').system();\n var hasSchema = false;\n var Dialog = null;\n \n function hasSystem() {\n var result = true;\n \n if (typeof system == 'undefined') {\n result = false;\n }\n if (typeof system !== 'undefined' && system.name() === 'default') {\n result = false;\n }\n \n return result;\n }\n \n if (hasSystem()) {\n hasSchema = Object.keys(system.schemas()).length !== 0;\n }\n \n if (!hasSystem()) {\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n } else {\n switch (true) {\n case menu === 'models' && !hasSchema:\n case menu === 'components' && !hasSchema:\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n break;\n default:\n this.require('workspace').create();\n break;\n }\n }\n }.bind(this));\n }\n}","useCoreAPI":false,"core":false},"j14bb21eb8a1b68a":{"_id":"j14bb21eb8a1b68a","component":"MessageHelp","state":"remove","action":"function remove() { \n if ($('#panel-message-help')) {\n\t $('#panel-message-help').remove();\n }\n}","useCoreAPI":false,"core":false},"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"_Storage","state":"get","action":"function get(key) {\n var result = null;\n\n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"_Storage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n\n store[key] = value;\n this.store(store);\n\n item[key] = JSON.stringify(value);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"_Storage","state":"clear","action":"function clear() {\n this.store({});\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear();\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"_Storage","state":"init","action":"function init(conf) {\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n\n length = keys.length;\n for (i = 0; i < length; i++) {\n try {\n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n } catch (e) { }\n }\n this.store(store);\n\n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n\n try {\n store[e.key] = JSON.parse(e.newValue);\n this.store(store);\n\n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n\n this.changed(obj);\n } catch (e) { }\n }.bind(this));\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"_Storage","state":"remove","action":"function remove(key) {\n var store = this.store();\n\n delete store[key];\n this.store(store);\n\n try {\n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key);\n break;\n default:\n break;\n }\n } catch (e) { }\n}","useCoreAPI":false,"core":true},"z14cf91f7131c34d":{"_id":"z14cf91f7131c34d","component":"1dbc51300e11z17","state":"click","action":"function click() {\n $('#designer-toolbar-item-search').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n\n var message = this.require('message');\n var Dialog = this.require('DialogSearch');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n}"},"a13b711adba1c7d4":{"_id":"a13b711adba1c7d4","component":"163a01b7ca1935c","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}"},"e137f915b1b15f90":{"_id":"e137f915b1b15f90","component":"163a01b7ca1935e","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}"},"p1087a100821fa03":{"_id":"p1087a100821fa03","component":"1dbc51200e116e3","state":"click","action":"function click() {\n $('#designer-toolbar-item-config').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogConfig = this.require('DialogConfig');\n\n DialogConfig = new DialogConfig({\n 'title': 'Configuration'\n });\n DialogConfig.show();\n DialogConfig.on('ok', function () {\n var message = this.require('message');\n\n this.hide();\n message.success('Configuration saved.');\n });\n}"},"y1163b139241a596":{"_id":"y1163b139241a596","component":"1dbc51200e116e11","state":"click","action":"function click() {\n $('#designer-toolbar-item-sync').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogSync = this.require('DialogSync');\n\n DialogSync = new DialogSync({\n 'title': 'GitHub'\n });\n DialogSync.show();\n DialogSync.on('ok', function () {\n if ($('#designer-dialog-sync-refresh').prop('checked')) {\n this.require('github').refresh();\n } else {\n this.require('github').push(\n $('#designer-dialog-sync-comments').val(),\n $('#designer-dialog-type-creation-hasHTML').prop('checked'),\n false,\n $('#designer-dialog-sync-options-log-level-select').val(),\n $('#designer-dialog-type-creation-hasPackage').prop('checked')\n );\n }\n this.hide();\n });\n}"},"o1ec561a54015768":{"_id":"o1ec561a54015768","component":"163a01b7ca1935d","state":"click","action":"function click() {\n $('#designer-toolbar-item-import').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogImportFile = this.require('DialogImportFile');\n\n var dialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n dialogImportFile.show();\n}"},"q178081a11712887":{"_id":"q178081a11712887","component":"13f70137b61b19b","state":"click","action":"function click() {\n var designer = this.require('designer'),\n message = this.require('message'),\n debugWindow = this.require('designer').debugWindow(),\n runWidow = this.require('designer').runWindow(),\n system = this.require('factory').system(),\n json = {},\n cleanJson = '',\n reg = null;\n\n $('#designer-toolbar-item-publish').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (system && system.name() !== 'default') {\n\n // force save befor running the app\n this.require('designer').save();\n\n\n switch(true) {\n // case of extension\n case system.name().indexOf('extension-') !== -1:\n json = this.require('factory').toJSON();\n\n cleanJson = JSON.stringify(json);\n reg = new RegExp(json._id, 'g');\n cleanJson = cleanJson.replace(reg, 'ext_' + json._id);\n json = JSON.parse(cleanJson);\n runtime.stop(json._id);\n runtime.uninstall(json._id);\n runtime.install(json);\n this.require('menubar').render();\n this.require('toolbar').render();\n message.success('The extension has been installed.');\n break;\n \n // case of remote debugging\n case debugWindow && !debugWindow.closed:\n this.require('channel').$designerSetSystem(this.require('factory').toJSON());\n // TODO Refresh the page\n message.success('Running the system in the remote page...');\n break;\n\n // reload the running page\n case runWidow && !runWidow.closed:\n runWidow.close();\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n\n /*if (typeof require === 'undefined') {\n runWidow.document.location.reload();\n message.success('Running the system...');\n } else {\n // TODO \n // to reload when implemented in electron\n message.info('info: to run again the system, click the widow where your system is running and go to the menu \\'View > Refresh\\’.');\n }*/\n break;\n\n // we load for the first time the page\n default:\n this.require('designer').runWindow(this.require('designer').open('app/index.html#' + this.require('factory').system().id(), 'app'));\n message.success('Running the system...');\n break;\n }\n } else {\n message.warning('There is no system to run.');\n }\n}","useCoreAPI":true},"k1a9e11cd571d17c":{"_id":"k1a9e11cd571d17c","component":"13a291c27f16314","state":"click","action":"function click() { \n $('#designer-toolbar-item-help').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n switch (this.require('state').menu()) {\n case 'systems':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-system.html', '_blank', true); \n break;\n case 'schemas':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-schema.html', '_blank', true); \n break;\n case 'models':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/edit-a-model.html', '_blank', true); \n break;\n case 'types':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-type.html', '_blank', true); \n break;\n case 'behaviors':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-behavior.html', '_blank', true); \n break;\n case 'components':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/create-a-component.html', '_blank', true); \n break;\n case 'logs':\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/run-your-system.html', '_blank', true);\n break;\n default:\n this.require('designer').open('https://designfirst.io/systemdesigner/documentation/docs/quick-start.html', '_blank', true); \n break;\n }\n}"},"o1ff8e17e1c1bcd7":{"_id":"o1ff8e17e1c1bcd7","component":"13a291c27f16310","state":"click","action":"function click() {\n $('#designer-toolbar-item-copyright').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogCopyright = this.require('DialogCopyright');\n var message = this.require('copyright.html');\n \n DialogCopyright = new DialogCopyright({\n 'title': 'System Designer',\n 'message': message.source().replace('{{version}}', this.require('designer').version())\n });\n DialogCopyright.show();\n DialogCopyright.on('ok', function () {\n this.hide();\n });\n}"},"c15ea3176d5139e8":{"_id":"c15ea3176d5139e8","component":"10bcb1a0511e09f","state":"click","action":"function click() { \n $('#designer-toolbar-item-create').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message'),\n designer = this.require('designer');\n \n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n this.require('workspace').create();\n }\n }\n}"},"l19fda1461e1d86c":{"_id":"l19fda1461e1d86c","component":"Spaces","state":"clear","action":"function clear() { \n this.require('state').space('');\n $('#designer-spaces-items').empty();\n}","useCoreAPI":false,"core":false},"a16e02190b216769":{"_id":"a16e02190b216769","component":"Spaces","state":"render","action":"function render() { \n var item = null,\n items = [],\n components = [],\n systemItems = [],\n system = this.require('factory').system(),\n SpaceItem = this.require('SpaceItem'),\n spaceItem = null,\n space = '',\n id = '',\n domItems = document.getElementById('designer-spaces-items'),\n systemdomItems = document.getElementById('designer-spaces-system-items'),\n componentdomItems = document.getElementById('designer-spaces-components-items'),\n self = this,\n name = '',\n callback = null,\n modelsName = [],\n showComponents = false,\n modelName = '',\n componentId = '',\n fragment = '';\n\n function _removeActive() {\n var length = 0,\n i = 0,\n item = null;\n\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n requestAnimationFrame(function () {\n $(item).removeClass('active');\n });\n }\n }\n\n function _findModel(compId, components) {\n var result = '',\n modelName = '';\n\n for (modelName in components) {\n if (typeof components[modelName][compId] !== 'undefined') {\n result = modelName;\n break;\n }\n }\n return result;\n }\n\n $('#designer-spaces-help').empty();\n\n // update header and help\n switch (this.require('state').menu()) {\n case 'systems':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Systems';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-system.html').getHTML());\n break;\n case 'schemas':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Schemas';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-schemas.html').getHTML());\n break;\n case 'models':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-models.html').getHTML());\n break;\n case 'types':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Types';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-types.html').getHTML());\n break;\n case 'behaviors':\n $('#designer-spaces-spaces-system').show();\n $('#designer-spaces-spaces-components').show();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n document.getElementById('designer-spaces-system-header').innerHTML = 'System';\n document.getElementById('designer-spaces-components-header').innerHTML = 'Components';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-behaviors.html').getHTML());\n break;\n case 'components':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Models';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-components.html').getHTML());\n break;\n case 'logs':\n $('#designer-spaces-spaces-system').hide();\n $('#designer-spaces-spaces-components').hide();\n document.getElementById('designer-spaces-type').innerHTML = 'Logs';\n // help\n document.getElementById('designer-spaces-help').insertAdjacentHTML('beforeend', this.require('help-logs.html').getHTML());\n break;\n default:\n break;\n }\n\n // update spaces\n // clear\n $('#designer-spaces-items').empty();\n $('#designer-spaces-system-items').empty();\n $('#designer-spaces-components-items').empty();\n if (system) {\n switch (this.require('state').menu()) {\n case 'systems':\n // items \n var systems = this.require('storage').get('system-designer-systems'),\n systemIds = [],\n length = 0,\n i = 0;\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n system = this.require('storage').get(systemIds[i]);\n\n if (system.name !== 'default') {\n spaceItem = new SpaceItem({\n 'name': system.name,\n 'uuid': system._id\n });\n \n items.push(spaceItem);\n }\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n \n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n this.items().forEach(function (item) {\n item.on('click', function () {\n var designer = this.require('designer'),\n system = this.require('storage').get(this.uuid()),\n System = this.require('System');\n \n if (system) {\n this.require('factory').create(system);\n }\n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n });\n });\n\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n if (this.require('factory').system()) {\n if ($('#designer-space-' + this.require('factory').system().name()).length) {\n $('#designer-space-' + this.require('factory').system().name()).addClass('active');\n this.require('state').space(this.require('factory').system().name());\n }\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n }\n\n break;\n case 'schemas':\n // items \n for (name in system.schemas()) {\n spaceItem = new SpaceItem({\n 'name': system.schemas()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n \n case 'models':\n // items \n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.uuid());\n }.bind(this));\n\n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).uuid());\n }\n } else {\n this.require('state').space('');\n }\n break;\n case 'types':\n // items\n for (name in system.types()) {\n spaceItem = new SpaceItem({\n 'name': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n break;\n case 'behaviors':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n \n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.items().reverse();\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n this.items().forEach(function (item) {\n modelsName.push(item.name());\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n\n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment); \n }\n \n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n\n // systems\n systemItems = []\n\n if (this.require('storage').get('system-designer-systems') && this.require('storage').get('system-designer-systems').systems.length) {\n if (this.require('factory').system().name() !== 'default') {\n spaceItem = new SpaceItem({\n 'name': this.require('factory').system().name(),\n 'uuid': this.require('factory').system().id()\n });\n systemItems.push(spaceItem);\n }\n }\n \n this.systems(systemItems);\n fragment = '';\n \n this.systems().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().unshift('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n systemdomItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = systemdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = systemdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.systems(i)));\n }\n\n space = this.require('state').space();\n if (modelsName.indexOf(space) !== -1) {\n showComponents = true;\n modelName = space;\n } else {\n modelName = _findModel(space, this.require('factory').system().components());\n if (modelName) {\n showComponents = true;\n }\n }\n\n if (showComponents) {\n\n // components\n components = [];\n\n // components\n for (id in system.components()[modelName]) {\n spaceItem = new SpaceItem({\n 'name': id,\n 'uuid': id\n });\n components.push(spaceItem);\n }\n\n this.components(components);\n\n // sort\n this.components().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n //this.components().reverse();\n\n fragment = '';\n \n this.components().forEach(function (item) {\n modelsName.push(item.name());\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n componentdomItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = componentdomItems.children.length;\n for (i = 0; i < length; i++) {\n item = componentdomItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.components(i)));\n }\n }\n\n // focus\n if (this.items().length > 0) {\n if ($('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).length) {\n $('#designer-space-' + this.require('state').space().replace(/\\./g, '-')).addClass('active');\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n if (this.systems(0)) {\n this.require('state').space(this.systems(0).name());\n }\n }\n } else {\n item = systemdomItems.children[0];\n $(item).addClass('active');\n if (this.systems(0)) {\n this.require('state').space(this.systems(0).name());\n }\n }\n\n break;\n \n case 'components':\n // items\n for (name in system.models()) {\n spaceItem = new SpaceItem({\n 'name': system.models()[name]._name,\n 'uuid': name\n });\n items.push(spaceItem);\n }\n this.items(items);\n\n // sort\n this.items().sort(function (idA, idB) {\n var a = runtime.require(idA),\n b = runtime.require(idB);\n\n var result = 0;\n if (a.name() > b.name()) {\n result = 1;\n }\n if (a.name() < b.name()) {\n result = -1;\n }\n return result;\n });\n\n this.require('state').navigation().spaces([]);\n fragment = '';\n \n this.items().forEach(function (item) {\n fragment = fragment + '
  • ' + item.name() + '
  • ';\n this.require('state').navigation().spaces().push('designer-space-' + item.name());\n }.bind(this));\n \n if (fragment) {\n domItems.insertAdjacentHTML('beforeend', fragment);\n }\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n item.addEventListener('click', function () {\n this.click();\n }.bind(self.items(i)));\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space(this.items(0).name());\n }\n }\n\n break;\n case 'logs':\n this.require('state').navigation().spaces([]);\n \n fragment = '';\n\n fragment = fragment + '
  • All logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-all');\n fragment = fragment + '
  • Error logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-error');\n fragment = fragment + '
  • Warning logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-warn');\n fragment = fragment + '
  • Info logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-info');\n fragment = fragment + '
  • Debug logs
  • ';\n this.require('state').navigation().spaces().push('designer-space-debug');\n \n domItems.insertAdjacentHTML('beforeend', fragment);\n\n // events\n callback = function () {\n _removeActive();\n $(this).addClass('active');\n };\n length = domItems.children.length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n item.addEventListener('click', callback);\n }\n // focus\n if (length > 0) {\n if ($('#designer-space-' + this.require('state').space()).length) {\n $('#designer-space-' + this.require('state').space()).addClass('active');\n } else {\n item = domItems.children[0];\n $(item).addClass('active');\n this.require('state').space('all');\n }\n }\n break;\n default:\n break;\n }\n }\n}","useCoreAPI":false,"core":false},"d1cb2d156c513e03":{"_id":"d1cb2d156c513e03","component":"Workspace","state":"init","action":"function init(conf) { \n var that = this;\n\n $('html')\n .on('dragenter dragover', false)\n .on('drop', function (e) {\n e.stopPropagation();\n e.preventDefault();\n var files = e.originalEvent.dataTransfer.files;\n var reader = new FileReader();\n var json = '';\n reader.onload = function (event) {\n json += event.target.result;\n };\n reader.onloadend = function () {\n try {\n var sys = JSON.parse(json);\n \n if (\n typeof sys._id !== 'undefined' &&\n typeof sys.name !== 'undefined' &&\n typeof sys.description !== 'undefined' &&\n typeof sys.version !== 'undefined' &&\n typeof sys.schemas !== 'undefined'\n ) {\n \n var DialogDropFile = that.require('DialogDropFile');\n \n if (!that.require('factory').system()) {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system.'\n });\n } else {\n DialogDropFile = new DialogDropFile({\n 'title': 'A system has been found',\n 'message': 'You can import the system or compose it with the current system.'\n });\n }\n \n DialogDropFile.data(sys);\n DialogDropFile.show();\n } else {\n that.require('message').warning('The file that you have dropped is not a valid system.');\n }\n } catch(e) {\n that.require('message').warning('The file that you have dropped is not a valid system.');\n }\n };\n if (files[0]) {\n reader.readAsText(files[0], 'UTF-8');\n }\n });\n}","useCoreAPI":false,"core":false},"v1090710e8e1d9f9":{"_id":"v1090710e8e1d9f9","component":"Workspace","state":"create","action":"function create() {\n var id = '',\n Dialog = null,\n dialog = null,\n factory = this.require('factory'),\n system = this.require('factory').system();\n\n switch (this.require('state').menu()) {\n case 'systems':\n Dialog = this.require('DialogSystemCreation');\n dialog = new Dialog({\n 'title': 'Create a new system',\n });\n dialog.show();\n break;\n case 'schemas':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogSchemaCreation');\n dialog = new Dialog({\n 'title': 'Create a new schema',\n });\n dialog.show();\n }\n break;\n case 'models':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogModelCreation');\n dialog = new Dialog({\n 'title': 'Create a new model',\n });\n dialog.show();\n }\n break;\n case 'types':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogTypeCreation');\n dialog = new Dialog({\n 'title': 'Create a new type',\n });\n dialog.show();\n }\n break;\n case 'components':\n if (system && Object.keys(system).length) {\n var models = this.require('factory').system().models(),\n component = {},\n ModelComponent = null,\n modelComponent = null,\n modelName = '';\n\n modelName = this.require('state').space();\n\n if (typeof models[modelName] === 'undefined') {\n \n this.require('message-help').remove();\n\n component = this.require('factory').addComponent(modelName);\n\n ModelComponent = this.require('ModelComponent');\n\n modelComponent = new ModelComponent({\n title: component._id\n });\n modelComponent.model(modelName);\n modelComponent.uuid(component._id);\n modelComponent.document(JSON.parse(JSON.stringify(component)));\n modelComponent.content(JSON.stringify(component));\n\n modelComponent.render();\n\n // little effect\n $('#designer-component-' + component._id).hide();\n $('#designer-component-' + component._id).fadeIn(1000);\n\n this.require('designer').save();\n\n this.require('channel').$designerCreateComponent(modelName, component);\n this.require('message').success('Component created.');\n } else {\n this.require('message').warning('There is no schema. Create a schema before creating a component.');\n }\n }\n break;\n case 'behaviors':\n if (system && Object.keys(system).length) {\n Dialog = this.require('DialogBehaviorCreation');\n dialog = new Dialog({\n 'title': 'Create a new behavior',\n });\n dialog.show();\n }\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":false},"f134d11639b1c4fe":{"_id":"f134d11639b1c4fe","component":"Workspace","state":"clear","action":"function clear() { \n // force hide tooltip\n $('.designer-model [data-toggle=\"tooltip\"]').tooltip('hide');\n $('.designer-type [data-toggle=\"tooltip\"]').tooltip('hide');\n \n jsPlumb.ready(function () {\n try {\n jsPlumb.deleteEveryEndpoint();\n } catch (e) {\n \n }\n });\n \n $('#designer-workspace').empty();\n}","useCoreAPI":false,"core":false},"i131bd1870a18e7a":{"_id":"i131bd1870a18e7a","component":"e89c617b6b15d28","state":"start","action":"function start() { \n var storeConfig = '';\n \n // set locale\n storeConfig = this.require('storage').get('system-designer-config');\n\n if (!storeConfig) {\n storeConfig = {};\n }\n\n if (typeof storeConfig.language === 'undefined') {\n storeConfig.language = 'en-US';\n this.require('storage').set('system-designer-config', storeConfig);\n } else {\n this.require('i18n').locale(storeConfig.language);\n }\n \n this.require('designer').render();\n}","useCoreAPI":false,"core":false},"l1b9611fc10168ec":{"_id":"l1b9611fc10168ec","component":"State","state":"logs","action":"function logs(value, type) { \n var html = '';\n var filter = this.require('state').space();\n var logNumber = 0;\n \n if (type === 'add') {\n if (this.require('state').menu() === 'logs') {\n switch (value.type()) {\n case 'debug':\n if (filter === 'all' || filter === 'debug' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'info':\n if (filter === 'all' || filter === 'info' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n } \n break;\n case 'warn':\n if (filter === 'all' || filter === 'warn' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n case 'error':\n if (filter === 'all' || filter === 'error' || filter === '') {\n html = '

    ' + value.log() + '

    ';\n }\n break;\n default:\n break;\n }\n \n document.querySelector('#designer-loug-output').insertAdjacentHTML('beforeend',\n html\n );\n } else {\n requestAnimationFrame(function() {\n // increment log number\n var logNumber = parseInt(document.querySelector('#designer-menu-item-logs-number').innerHTML, 10);\n document.querySelector('#designer-menu-item-logs-number').innerHTML = logNumber + 1;\n $('#designer-menu-item-logs-number').show();\n });\n }\n }\n}","useCoreAPI":false,"core":false},"p1d00311ad51ef9a":{"_id":"p1d00311ad51ef9a","component":"Designer","state":"welcome","action":"function welcome() { \n var Dialog = null,\n dialog = null,\n config = null;\n\n config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n\n if (typeof config.welcomeScreen === 'undefined') {\n Dialog = this.require('DialogWelcome');\n dialog = new Dialog({\n 'title': 'Welcome to System Designer'\n });\n dialog.show();\n dialog.on('ok', function ok() {\n var config = this.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n config.welcomeScreen = false;\n this.require('storage').set('system-designer-config', config);\n this.hide();\n });\n }\n}","useCoreAPI":false,"core":false},"o12c7d1448a1dc16":{"_id":"o12c7d1448a1dc16","component":"Designer","state":"render","action":"function render() {\n var System = null,\n systemId = '',\n config = {};\n\n // message\n this.require('logger').on('warn', function warn(message) {\n this.require('message').warning(message);\n });\n this.require('logger').on('error', function error(message) {\n this.require('message').danger(message);\n });\n\n // extensions\n this.installExtensions();\n\n // system\n System = this.require('System');\n var systems = this.require('storage').get('system-designer-systems');\n\n // case of url\n switch (true) {\n case window.location.href.split('#').length > 1 && window.location.href.split('#')[1].length > 0:\n systemId = window.location.href.split('#')[1];\n if (this.require('storage').get(systemId)) {\n this.require('factory').create(this.require('storage').get(systemId));\n }\n break;\n default:\n if (systems && systems.systems && systems.systems.length && systems.systems[0].length) {\n systems.systems.sort(function (sysA, sysB) {\n var a = this.require('storage').get(sysA),\n b = this.require('storage').get(sysB),\n result = 0;\n\n if (a.name > b.name) {\n result = 1;\n }\n if (a.name < b.name) {\n result = -1;\n }\n return result;\n }.bind(this));\n\n this.require('factory').create(this.require('storage').get(systems.systems[0]));\n }\n break;\n }\n\n this.welcome();\n\n this.require('router').start();\n\n if (typeof document.ontouchstart === 'undefined') {\n // resize event\n $(window).resize(function() {\n jsPlumb.repaintEverything();\n });\n } else {\n // orientation change event\n window.addEventListener('orientationchange', function() {\n setTimeout(function() {\n window.scrollTo(0, 0);\n if (typeof jsPlumb !== 'undefined') {\n jsPlumb.repaintEverything();\n }\n }, 100);\n });\n }\n\n this.require('menubar').render();\n this.require('toolbar').render();\n this.require('spaces').render();\n\n this.addShorcuts();\n\n // run messages if any\n this.runMessages(this.require('state').messages());\n this.require('state').messages([]);\n\n // install PWA\n window.addEventListener('beforeinstallprompt', (e) => {\n var config = runtime.require('storage').get('system-designer-config');\n if (!config) {\n config = {};\n }\n if (typeof config.pwaInstalled === 'undefined' && config.welcomeScreen === false) {\n config.pwaInstalled = false;\n this.require('storage').set('system-designer-config', config);\n\n e.preventDefault();\n var Dialog = runtime.require('DialogInstallPWA');\n var dialog = new Dialog({ 'title': 'Install System Designer' });\n dialog.deferredPrompt(e);\n dialog.show();\n }\n });\n}","useCoreAPI":false,"core":false},"x196fc166ef17a85":{"_id":"x196fc166ef17a85","component":"Designer","state":"linkModel","action":"function linkModel(source, target) { \n jsPlumb.ready(function () {\n jsPlumb.setContainer('body');\n\n jsPlumb.connect({\n paintStyle: {\n stroke: '#7F949D',\n strokeWidth: 3\n },\n source: 'designer-model-panel-' + source,\n target: 'designer-model-panel-' + target,\n overlays: [\n ['Arrow', {\n location: 1\n }]\n ]\n }, {\n connector: ['Flowchart'],\n anchor: ['Left', 'Right'],\n endpoint: 'Blank'\n });\n });\n}","useCoreAPI":false,"core":false},"k13951153851cc3a":{"_id":"k13951153851cc3a","component":"Designer","state":"save","action":"function save() { \n var systems = this.require('storage').get('system-designer-systems'),\n system = this.require('factory').toJSON(),\n systemId = system._id;\n\n // save system\n this.require('storage').set(systemId, system);\n\n // save index\n if (!systems) {\n systems = { 'systems': [systemId] };\n } else {\n if (systems.systems.indexOf(systemId) === -1) {\n systems.systems.push(systemId);\n }\n }\n this.require('storage').set('system-designer-systems', systems);\n}","useCoreAPI":false,"core":false},"u1cf0e155fb1e53f":{"_id":"u1cf0e155fb1e53f","component":"Workspace","state":"render","action":"function render() { \n var ModelSystem = null,\n ModelSchema = null,\n ModelClass = null,\n modelSchema = null,\n ModelLog = null,\n sys = null,\n name = '',\n id = '',\n schemaId = '',\n modelclass = null,\n modellog = null,\n ModelType = null,\n type = null,\n ModelComponent = null,\n component = null,\n ModelBehavior = null,\n behavior = null,\n system = this.require('factory').system(),\n space = this.require('state').space(),\n menu = this.require('state').menu(),\n systemStore = {};\n parentId = '',\n parentsId = [],\n parents = null,\n systems = null,\n systemIds = [],\n i = 0,\n length = 0,\n title = 0,\n nbElement = 0;\n\n function _getSchemaId(name) {\n var result = '',\n id = '';\n\n for (id in system.schemas()) {\n if (system.schemas()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelId(name) {\n var result = '',\n id = '';\n\n for (id in system.models()) {\n if (system.models()[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n if (system && system.name() !== 'default') {\n this.clear();\n\n window.scrollTo(0, 0);\n\n title = 'system ' + system.name();\n if (title !== document.title) {\n document.title = title;\n }\n\n switch (this.require('state').menu()) {\n case 'systems':\n systems = this.require('storage').get('system-designer-systems');\n\n if (systems) {\n systemIds = systems.systems;\n }\n length = systemIds.length;\n\n for (i = 0; i < length; i++) {\n systemStore = this.require('storage').get(systemIds[i]);\n if (systemStore.name === space) {\n ModelSystem = this.require('ModelSystem');\n sys = new ModelSystem({\n 'title': systemStore.name\n });\n sys.uuid(systemStore._id);\n sys.document(JSON.parse(JSON.stringify(systemStore)));\n sys.content(JSON.stringify(systemStore));\n sys.render();\n }\n }\n\n if (space === '' && length > 0) {\n this.require('message').warning('System not found.');\n }\n\n break;\n case 'schemas':\n if (space) {\n for (id in system.schemas()) {\n if (system.schemas()[id]._id === space) {\n ModelSchema = this.require('ModelSchema');\n\n // create parent if any\n parentsId = [];\n if (system.schemas()[id]._inherit) {\n parents = system.schemas()[id]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n parentId = _getSchemaId(parents[i]);\n\n modelSchema = new ModelSchema({\n 'title': parents[i]\n });\n \n if (parents[i] !== system.schemas()[id]._name) {\n if (parents[i] === '_Component') {\n parentId = \"111df11e2b19fde\";\n \n var schemaRuntime = {\n \"_id\": \"_Component\",\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": \"property\",\n \"classInfo\": \"method\",\n \"init\": \"method\",\n \"destroy\": \"method\",\n \"on\": \"method\",\n \"off\": \"method\",\n \"require\": \"method\",\n \"error\": \"event\"\n };\n \n modelSchema.document(schemaRuntime);\n modelSchema.content(JSON.stringify(schemaRuntime));\n parentsId.push(parentId);\n modelSchema.uuid(parentId);\n } else {\n if (system.schemas()[_getSchemaId(parents[i])]) {\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[_getSchemaId(parents[i])])));\n modelSchema.content(JSON.stringify(system.schemas()[_getSchemaId(parents[i])]));\n parentsId.push(_getSchemaId(parents[i]));\n modelSchema.uuid(_getSchemaId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelSchema.uuid(parents[i]);\n }\n }\n modelSchema.render();\n }\n }\n\n modelSchema = new ModelSchema({\n 'title': system.schemas()[id]._name\n });\n modelSchema.uuid(id);\n modelSchema.document(JSON.parse(JSON.stringify(system.schemas()[id])));\n modelSchema.content(JSON.stringify(system.schemas()[id]));\n modelSchema.editable(true);\n modelSchema.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'models':\n if (space) {\n for (id in system.models()) {\n if (system.models()[id]._id === space) {\n ModelClass = this.require('ModelClass');\n\n // create parent if any\n // parents are search from the schema\n schemaId = _getSchemaId(system.models()[id]._name);\n parentsId = [];\n if (schemaId && system.schemas()[schemaId]._inherit) {\n parents = system.schemas()[schemaId]._inherit.slice();\n parents.reverse();\n }\n length = 0;\n if (parents) {\n length = parents.length;\n }\n\n for (i = 0; i < length; i++) {\n\n parentId = _getSchemaId(parents[i]);\n\n modelclass = new ModelClass({\n 'title': parents[i]\n });\n\n if (parents[i] === '_Component') {\n parentId = '123751cb591de26';\n\n var modelRuntime = {\n \"_name\": \"_Component\",\n \"_core\": true,\n \"id\": {\n \"description\": \"get the unique ID of a component\",\n \"type\": \"string\",\n \"readOnly\": true,\n \"mandatory\": false,\n \"default\": \"\"\n },\n \"classInfo\": {\n \"description\": \"get the model of the component\",\n \"result\": \"_ClassInfo\"\n },\n \"init\": {\n \"description\": \"action to do when the component is created\",\n \"params\": [{\n \"name\": \"conf\",\n \"type\": \"object\"\n }]\n },\n \"destroy\": {\n \"description\": \"action to do when the component is destroyed\",\n \"params\": []\n },\n \"on\": {\n \"description\": \"add a behavior to a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"action\",\n \"type\": \"function\"\n },\n {\n \"name\": \"useCoreAPI\",\n \"type\": \"boolean\",\n \"mandatory\": false\n },\n {\n \"name\": \"isCore\",\n \"type\": \"boolean\",\n \"mandatory\": false\n }\n ],\n \"result\": \"string\"\n },\n \"off\": {\n \"description\": \"remove a behavior from a component\",\n \"params\": [{\n \"name\": \"state\",\n \"type\": \"string\"\n },\n {\n \"name\": \"behaviorId\",\n \"type\": \"string\",\n \"mandatory\": false\n }]\n },\n \"require\": {\n \"description\": \"require a component\",\n \"params\": [{\n \"name\": \"id\",\n \"type\": \"string\"\n }],\n \"result\": \"_Component\"\n },\n \"error\": {\n \"description\": \"action to do when an error happened\",\n \"params\": [{\n \"name\": \"data\",\n \"type\": \"errorParam\"\n }]\n }\n };\n\n modelclass.document(modelRuntime);\n modelclass.content(JSON.stringify(modelRuntime));\n parentsId.push(parentId);\n modelclass.uuid(parentId);\n } else {\n if (system.models()[_getModelId(parents[i])]) {\n modelclass.document(JSON.parse(JSON.stringify(system.models()[_getModelId(parents[i])])));\n modelclass.content(JSON.stringify(system.models()[_getModelId(parents[i])]));\n parentsId.push(_getModelId(parents[i]));\n modelclass.uuid(_getModelId(parents[i]));\n } else {\n parentsId.push(parents[i]);\n modelclass.uuid(parentId);\n }\n }\n modelclass.render();\n }\n\n modelclass = new ModelClass({\n 'title': system.models()[id]._name\n });\n modelclass.uuid(id);\n modelclass.document(JSON.parse(JSON.stringify(system.models()[id])));\n modelclass.content(JSON.stringify(system.models()[id]));\n modelclass.editable(true);\n modelclass.render();\n\n length = parentsId.length;\n for (i = 0; i < length; i++) {\n this.require('designer').linkModel(id, parentsId[i]);\n }\n }\n }\n } else {\n if (Object.keys(system.schemas()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'types':\n if (space) {\n for (name in system.types())\n if (system.types()[name].name === space) {\n ModelType = this.require('ModelType');\n type = new ModelType({\n 'title': name\n });\n type.uuid(name);\n type.document(JSON.parse(JSON.stringify(system.types()[space])));\n type.content(JSON.stringify(system.types()[space]));\n type.render();\n }\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n } else {\n if (Object.keys(system.types()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'components':\n var nbComponents = 0;\n if (space) {\n if (this.require('state').component()) {\n name = this.require('state').component();\n if (system.components()[space] && system.components()[space][name]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n } else {\n this.require('message-help').render();\n }\n } else {\n for (name in system.components()[space]) {\n ModelComponent = this.require('ModelComponent');\n component = new ModelComponent({\n 'title': name\n });\n component.uuid(name);\n component.model(space);\n component.document(JSON.parse(JSON.stringify(system.components()[space][name])));\n component.content(JSON.stringify(system.components()[space][name]));\n component.render();\n nbComponents = nbComponents + 1;\n \n if (nbComponents === 50) {\n this.require('message').warning('For performance reason you will only see the first 50 components.');\n break;\n }\n }\n \n if (system.components()) {\n if (system.components()[space]) {\n if (Object.keys(system.components()[space]).length === 0) {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n } else {\n this.require('message-help').render();\n }\n }\n } else {\n if (Object.keys(system.components()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'behaviors':\n if (space) {\n name = this.require('state').component();\n var behaviorDef = {};\n var behaviorsId = Object.keys(system.behaviors());\n var systemName = this.require('factory').system().name();\n var systemId = this.require('factory').system().id();\n ModelBehavior = this.require('ModelBehavior');\n \n behaviorsId.forEach(function(id) {\n behaviorDef = system.behaviors()[id];\n if (behaviorDef.component === space) {\n if ((name && behaviorDef.state === name) || name === '') {\n behavior = new ModelBehavior({\n 'uuid': system.behaviors()[id]._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n\n // system\n if (space === systemName) {\n if (behaviorDef.component === systemId) {\n behavior = new ModelBehavior({\n 'uuid': behaviorDef._id\n });\n behavior.title(behaviorDef.state);\n behavior.document(behaviorDef);\n behavior.content(JSON.parse(JSON.stringify(behaviorDef.action)));\n behavior.render();\n \n nbElement = nbElement + 1;\n }\n }\n }.bind(this));\n \n if (nbElement === 0) {\n this.require('message-help').render();\n } else {\n Prism.highlightAll();\n }\n } else {\n if (Object.keys(system.behaviors()).length === 0) {\n this.require('message-help').render();\n }\n }\n break;\n case 'logs':\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n $('#designer-menu-item-logs-number').hide();\n \n ModelLog = this.require('ModelLog');\n\n modelLog = new ModelLog();\n modelLog.render();\n\n break;\n default:\n break;\n }\n } else {\n\n document.title = '';\n document.title = 'System Designer';\n \n this.require('message-help').render();\n \n if (system && system.name() === 'default') {\n this.require('message').warning('System not found: the system has been deleted.');\n } else {\n systems = this.require('storage').get('system-designer-systems');\n if (systems && systems.systems && systems.systems.length) {\n this.require('message').warning('System not found: click on the Systems tab to reload your context.');\n }\n }\n }\n}","useCoreAPI":false,"core":false},"s1876e1b64c1251e":{"_id":"s1876e1b64c1251e","component":"Router","state":"update","action":"function update() { \n var menubar = [],\n i = 0,\n length = 0,\n collection = '',\n href = '',\n context = '',\n space = '',\n schemaName = '',\n schemaId = '',\n modelName = '',\n modelId = '';\n \n function _getModelId(name, models) {\n var result = '',\n id = '';\n\n for (id in models) {\n if (models[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaId(name, schemas) {\n var result = '',\n id = '';\n\n for (id in schemas) {\n if (schemas[id]._name === name) {\n result = id;\n break;\n }\n }\n return result;\n }\n\n function _getModelName(id, models) {\n var result = '',\n modelId = '';\n\n for (modelId in models) {\n if (modelId === id) {\n result = models[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getSchemaName(id, schemas) {\n var result = '',\n schemaId = '';\n\n for (schemaId in schemas) {\n if (schemaId === id) {\n result = schemas[id]._name;\n break;\n }\n }\n return result;\n }\n\n function _getCollection(href) {\n var result = '';\n\n if (href.split('#').length === 2) {\n result = href.split('#')[1];\n }\n if (href.split('#').length > 2) {\n result = href.split('#')[2];\n }\n\n result = result.split('#')[0];\n result = result.trim();\n\n return result;\n }\n\n context = this.require('state').menu();\n space = this.require('state').space();\n\n switch (context) {\n case 'schemas':\n if (this.require('factory').system()) {\n if (space) {\n schemaName = _getSchemaName(space, this.require('factory').system().schemas());\n modelId = _getModelId(schemaName, this.require('factory').system().models());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n if (collection === 'behaviors' && schemaName) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'models':\n if (this.require('factory').system()) {\n if (space) {\n modelName = _getModelName(space, this.require('factory').system().models());\n schemaId = _getSchemaId(modelName, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'components' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n if (collection === 'behaviors' && modelName) {\n menubar[i].href = menubar[i].href + '#' + modelName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'behaviors':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'components' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n case 'components':\n if (this.require('factory').system()) {\n if (space) {\n modelId = _getModelId(space, this.require('factory').system().models());\n schemaId = _getSchemaId(space, this.require('factory').system().schemas());\n schemaName = _getSchemaName(schemaId, this.require('factory').system().schemas());\n }\n\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n\n if (collection === 'schemas' && schemaId) {\n menubar[i].href = menubar[i].href + '#' + schemaId;\n }\n if (collection === 'models' && modelId) {\n menubar[i].href = menubar[i].href + '#' + modelId;\n }\n if (collection === 'behaviors' && modelId) {\n menubar[i].href = menubar[i].href + '#' + schemaName;\n }\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n default:\n if (this.require('factory').system()) {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '#' + this.require('factory').system().id() + '#' + collection;\n }\n } else {\n menubar = $('#designer-menubar-items > li > a');\n length = menubar.length;\n for (i = 0; i < length; i++) {\n href = menubar[i].href;\n collection = _getCollection(href);\n menubar[i].href = '##' + collection;\n }\n }\n break;\n }\n}","useCoreAPI":false,"core":false},"a1e92e1b7d6162ab":{"_id":"a1e92e1b7d6162ab","component":"Router","state":"start","action":"function start() { \n var that = this;\n \n window.onhashchange = function (e) {\n var arr = window.location.href.split('#'),\n system = '',\n collection = 'systems',\n component = '',\n i = 0,\n length = 0,\n item = null,\n domItems = null,\n System = that.require('System'),\n systems = that.require('storage').get('system-designer-systems');\n\n if (arr.length > 1) {\n system = arr[1];\n system = system.split('?')[0];\n }\n\n if (arr.length > 2) {\n collection = arr[2];\n collection = collection.split('?')[0];\n }\n\n if (arr.length > 3) {\n component = arr[3];\n component = component.split('?')[0];\n }\n\n if (arr.length > 4) {\n that.require('state').component(arr[4].split('?')[0]);\n } else {\n that.require('state').component('');\n }\n \n if (arr.length > 1 && system) {\n that.require('factory').create(that.require('storage').get(system));\n } else {\n if (systems && systems.systems && systems.systems.length) {\n that.require('factory').create(that.require('storage').get(systems.systems[0]));\n }\n }\n \n that.require('state').space(decodeURIComponent(component));\n that.require('state').menu(decodeURIComponent(collection));\n\n // focus\n domItems = document.getElementById('designer-menubar-items');\n length = that.require('menubar').items().length;\n for (i = 0; i < length; i++) {\n item = domItems.children[i];\n $(item).removeClass('active');\n }\n for (i = 0; i < length; i++) {\n if (that.require('menubar').items(i).name() === collection) {\n item = domItems.children[i];\n $(item).addClass('active');\n }\n }\n\n that.update();\n };\t\n}","useCoreAPI":false,"core":false},"v10ccc18f431a78e":{"_id":"v10ccc18f431a78e","component":"State","state":"menu","action":"function menu(value) { \n jsPlumb.ready(function () {\n try {\n jsPlumb.deleteEveryEndpoint();\n } catch (e) {\n }\n });\n\n this.require('spaces').render();\n this.require('workspace').clear();\n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"n17df1112301e0cf":{"_id":"n17df1112301e0cf","component":"State","state":"space","action":"function space(value) { \n if (this.menu() === 'systems') {\n this.require('router').update();\n }\n}","useCoreAPI":false,"core":false},"j1fc1a152e61a7b9":{"_id":"j1fc1a152e61a7b9","component":"_Channel","state":"send","action":"function send(message) { \n if (message.event.indexOf('$system') !== 0) {\n var config = this.require('storage').get('system-designer-config');\n // message for other windows\n this.require('storage').set('system-designer-message', message);\n\n // message for client debug\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(message), '*');\n }\n\n // message for server debug\n if (typeof config !== 'undefined' && typeof config.debugType !== 'undefined' && config.debugType === 'server' && config.urlServer) {\n $.post(config.urlServer.replace(':8888', '') + ':8888/' + message.event, encodeURIComponent(JSON.stringify(message.data)));\n }\n }\t\n}","useCoreAPI":false,"core":false},"s11b84108ec12d82":{"_id":"s11b84108ec12d82","component":"_Channel","state":"$appLogDebug","action":"function $appLogDebug(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'debug',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'debug: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"s1274812bab1ab3d":{"_id":"s1274812bab1ab3d","component":"_Channel","state":"$appLogInfo","action":"function $appLogInfo(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'info',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'info: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').info(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"b1c5cb1ee0b195fc":{"_id":"b1c5cb1ee0b195fc","component":"_Channel","state":"$appLogWarn","action":"function $appLogWarn(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'warn',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'warning: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').warning(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"i1b8de1d60316328":{"_id":"i1b8de1d60316328","component":"_Channel","state":"$appLogError","action":"function $appLogError(message) { \n var log = '',\n Log = null;\n\n Log = this.require('Log');\n log = new Log({\n 'type': 'error',\n 'log': message.replace('runtime:', '').replace(/\\[[^\\]]+\\]/, 'error: ')\n });\n\n this.require('state').logs().push(log);\n this.require('message').danger(message.replace(/\\[[^\\]]+\\]/, 'runtime: '));\t\n}","useCoreAPI":false,"core":false},"h1ad061990d1bcc5":{"_id":"h1ad061990d1bcc5","component":"_Channel","state":"$editorUpdateType","action":"function $editorUpdateType(id, type) { \n this.require('factory').updateType(id, type);\n\n this.require('designer').save();\n\n this.require('state').space(type.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"h1275e1a9791051a":{"_id":"h1275e1a9791051a","component":"_Channel","state":"$editorDeleteType","action":"function $editorDeleteType(id) { \n var dbTypes = [],\n type = null;\n\n dbTypes = this.require('db').collections().ModelType.find({\n 'uuid': id\n });\n if (dbTypes.length) {\n type = this.require(dbTypes[0]._id);\n if (type) {\n type.hide();\n type.destroy();\n }\n }\n\n this.require('factory').deleteType(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1b3231dd52189ee":{"_id":"u1b3231dd52189ee","component":"_Channel","state":"$editorUpdateSchemaName","action":"function $editorUpdateSchemaName(name, id) { \n this.require('factory').updateSchemaName(name, id);\n \n this.require('designer').save();\t\n}","useCoreAPI":false,"core":false},"w17e86178ff1ac10":{"_id":"w17e86178ff1ac10","component":"_Channel","state":"$editorUpdateSchema","action":"function $editorUpdateSchema(id, schema) { \n var oldModel = this.require('factory').getGeneratedModel(schema._name);\n schemas = this.require('factory').system().schemas(),\n models = null,\n model = null,\n modelId = '';\n\n this.require('factory').syncModel(schema);\n \n this.require('designer').save();\n \n this.require('factory').updateSchema(id, schema);\n \n this.require('designer').save();\n\n // sync other components\n models = this.require('factory').system().models();\n for (modelId in models) {\n if (models[modelId]._name !== schema._name) {\n model = models[modelId];\n this.require('factory').syncComponent(model, oldModel, true);\n }\n }\n \n this.require('designer').save();\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"f14bae11650167a7":{"_id":"f14bae11650167a7","component":"_Channel","state":"$editorUpdateSchemaId","action":"function $editorUpdateSchemaId(oldId, newId) { \n this.require('factory').updateSchemaId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"n1cd861eb1d1d0a5":{"_id":"n1cd861eb1d1d0a5","component":"_Channel","state":"$editorUpdateModel","action":"function $editorUpdateModel(id, model) { \n var oldModel = this.require('factory').getGeneratedModel(model._name);\n\n this.require('factory').updateModel(id, model);\n\n this.require('designer').save();\n\n this.require('factory').syncBehavior(model);\n \n this.require('designer').save();\n \n this.require('factory').syncComponent(model, oldModel, true);\n\n this.require('state').space(id);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n \n $(function () {\n $('[role=\"tooltip\"]').hide();\n $('[data-toggle=\"tooltip\"]').tooltip({ 'container': 'body', delay: { 'show': 1500, 'hide': 100 }, trigger: 'hover' });\n });\n}","useCoreAPI":false,"core":false},"n1a1a113960107dd":{"_id":"n1a1a113960107dd","component":"_Channel","state":"$editorUpdateModelId","action":"function $editorUpdateModelId(oldId, newId) { \n this.require('factory').updateModelId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1219c18bd215028":{"_id":"m1219c18bd215028","component":"_Channel","state":"$designerUpdateBehavior","action":"function $designerUpdateBehavior(id, behavior) { \n this.require('factory').udpdateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"g1271811dd61f96f":{"_id":"g1271811dd61f96f","component":"_Channel","state":"$editorDeleteBehavior","action":"function $editorDeleteBehavior(id) { \n var dbBehaviors = [],\n behavior = null;\n\n dbBehaviors = this.require('db').collections().ModelBehavior.find({\n 'uuid': id\n });\n if (dbBehaviors.length) {\n behavior = this.require(dbBehaviors[0]._id);\n if (behavior) {\n behavior.hide();\n behavior.destroy();\n }\n }\n\n this.require('factory').deleteBehavior(id);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"m1433e1b8e71050a":{"_id":"m1433e1b8e71050a","component":"_Channel","state":"$editorUpdateComponent","action":"function $editorUpdateComponent(id, collection, component) { \n this.require('factory').overwriteComponent(id, collection, component);\n\n this.require('designer').save();\n\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"e1acfa1989b122ec":{"_id":"e1acfa1989b122ec","component":"_Channel","state":"$editorDeleteComponent","action":"function $editorDeleteComponent(id, collection) { \n var models = [],\n model = null;\n\n models = this.require('db').collections().ModelComponent.find({\n 'uuid': id\n });\n if (models.length) {\n model = this.require(models[0]._id);\n if (model) {\n model.hide();\n model.destroy();\n }\n }\n\n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"x11f721f8111c41a":{"_id":"x11f721f8111c41a","component":"_Channel","state":"$editorUpdateSystem","action":"function $editorUpdateSystem(id, system) { \n this.require('factory').updateSystem(id, system);\n \n this.require('designer').save();\n\n this.require('state').space(system.name);\n \n this.require('spaces').render();\n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"d180f31873a19ef7":{"_id":"d180f31873a19ef7","component":"_Channel","state":"$appLoadSystem","action":"function $appLoadSystem(system) { \n var Dialog = null,\n dialog = null,\n message = this.require('message');\n\n if (system.name) {\n if (system.name !== 'designer-runtime') {\n Dialog = this.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you want to import the system ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n \n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n }\n } else {\n message.warning('There is no system to import.');\n }\n}","useCoreAPI":false,"core":false},"r1318213d401b598":{"_id":"r1318213d401b598","component":"_Channel","state":"$runtimeCreateComponent","action":"function $runtimeCreateComponent(collection, component) { \n this.require('factory').createComponent(collection, component);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\t\n}","useCoreAPI":false,"core":false},"a125ea107d41f237":{"_id":"a125ea107d41f237","component":"_Channel","state":"$runtimeDeleteComponent","action":"function $runtimeDeleteComponent(id, collection) { \n this.require('factory').deleteComponent(id, collection);\n\n this.require('designer').save();\n\n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"n1636d1853518a09":{"_id":"n1636d1853518a09","component":"_Channel","state":"$runtimeUpdateComponent","action":"function $runtimeUpdateComponent(id, collection, field, value) { \n this.require('factory').updateComponent(id, collection, field, value);\n \n this.require('designer').save();\n \n if (this.require('state').menu() === 'components') {\n this.require('workspace').render();\n }\n}","useCoreAPI":false,"core":false},"v165f81ca0d1bd5f":{"_id":"v165f81ca0d1bd5f","component":"_Channel","state":"$designerDeleteSchema","action":"function $designerDeleteSchema(id) { \n var dbSchemas = [],\n schema = null;\n\n dbSchemas = this.require('db').collections().ModelSchema.find({\n 'uuid': id\n });\n if (dbSchemas.length) {\n schema = this.require(dbSchemas[0]._id);\n if (schema) {\n schema.hide();\n schema.destroy();\n }\n }\n\n this.require('factory').deleteSchema(id, false);\n \n this.require('designer').save();\n \n this.require('workspace').render();\t\n}","useCoreAPI":false,"core":false},"u1a9411d65313eb8":{"_id":"u1a9411d65313eb8","component":"_Channel","state":"$editorUpdateBehavior","action":"function $editorUpdateBehavior(id, behavior) { \n this.require('factory').updateBehavior(id, behavior);\n\n this.require('designer').save();\n \n this.require('workspace').render();\n}","useCoreAPI":false,"core":false},"s192131208d1553f":{"_id":"s192131208d1553f","component":"_Channel","state":"init","action":"function init(conf) { \n window.addEventListener('message', function message(event) {\n var data = null,\n config = this.require('storage').get('system-designer-config');\n\n if (!config) {\n config = {};\n }\n data = JSON.parse(event.data);\n if (data &&\n typeof data.event !== 'undefined' &&\n typeof data.from !== 'undefined' &&\n typeof data.data !== 'undefined') {\n $db._Message.insert(data);\n }\n }.bind(this), false);\n\n this.require('_Storage').on('changed', function changed(obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n if (this.require('designer').debugWindow()) {\n this.require('designer').debugWindow().postMessage(JSON.stringify(obj['system-designer-message'].newValue), '*');\n }\n $db._Message.insert(obj['system-designer-message'].newValue);\n }\n }, true);\t\n}","useCoreAPI":true,"core":false},"i1fa311dc26116f8":{"_id":"i1fa311dc26116f8","component":"y187401decb196c4","state":"click","action":"function click() {\n $('#designer-toolbar-item-export').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var message = this.require('message');\n var Dialog = this.require('DialogExport');\n var system = this.require('factory').system();\n\n if (system && system.name() !== 'default') {\n var dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n}","useCoreAPI":false,"core":false},"f1ae6e164301b982":{"_id":"f1ae6e164301b982","component":"x1371910b7812e58","state":"click","action":"function click() {\n var debugWindow = this.require('designer').debugWindow(),\n config = this.require('storage').get('system-designer-config'),\n message = this.require('message');\n\n $('#designer-toolbar-item-refresh').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n if (config) {\n if (typeof config.debugType !== 'undefined' && config.debugType === 'client') {\n if (config.urlClient) {\n if (debugWindow && !debugWindow.closed) {\n message.success('Searching for a system...');\n this.require('channel').$designerSync();\n } else {\n message.success('Opening the page...');\n this.require('designer').debugWindow(this.require('designer').open(config.urlClient, 'debug'));\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType !== 'undefined' && config.debugType === 'server') {\n if (config.urlServer) {\n message.success('Searching for a server...');\n var self = this;\n $.getJSON(config.urlServer.replace(':8888', '') + ':8888/$designerSync', function (system) {\n var Dialog = null,\n dialog = null,\n message = runtime.require('message');\n \n if (system && system.name) {\n Dialog = self.require('DialogImport');\n dialog = new Dialog({\n 'title': 'A system has been found',\n 'message': 'Do you wan to import it ?',\n 'data': system\n });\n dialog.show();\n \n dialog.on('ok', function () {\n var sys = null,\n designer = this.require('designer'),\n message = this.require('message');\n \n if (this.require('factory').system()) {\n this.require('factory').system().destroy();\n }\n \n sys = this.require('factory').create(this.data());\n \n // empty log\n this.require('state').logs().forEach(function (item) {\n this.logs().pop();\n }.bind(this.require('state')));\n \n // hide log\n $('#designer-menu-item-logs-number').hide();\n document.querySelector('#designer-menu-item-logs-number').innerHTML = 0;\n \n designer.save();\n \n this.require('state').space(sys.name());\n this.require('spaces').render();\n this.require('workspace').render();\n \n this.require('router').update();\n \n this.hide();\n designer.save();\n \n message.success('Importation of the system is done.');\n });\n } else {\n message.warning('There is no system to import.');\n }\n });\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n }\n if (typeof config.debugType === 'undefined') {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n } else {\n message.warning('No url set. Please set the url in the configuration panel.');\n }\n}","useCoreAPI":false,"core":false},"q141da1eb5d1916b":{"_id":"q141da1eb5d1916b","component":"g12f9e166c71cf91","state":"click","action":"function click() {\n $('#designer-toolbar-item-extension').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var DialogExtension = this.require('DialogExtension');\n\n DialogExtension = new DialogExtension({\n 'title': 'Manage your extensions'\n });\n DialogExtension.show();\n}","useCoreAPI":false,"core":false},"k1f66b12b5f1b625":{"_id":"k1f66b12b5f1b625","component":"l1f2871e69b1b85e","state":"click","action":"function click() { \n $('#designer-toolbar-item-command').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n if ($('#designer-dialog-command-modal').length) {\n $('#designer-dialog-input-command').val('');\n $('#designer-dialog-command-result').empty();\n $('#designer-dialog-command-result-area').hide();\n $('#designer-dialog-command-modal').modal('show');\n } else {\n var Dialog = runtime.require('DialogCommand');\n var dialog = new Dialog({'title':''});\n dialog.show();\n }\t\n } else {\n this.require('message').warning('There is no system.');\n }\n}","useCoreAPI":false,"core":false},"y1eaaf1fe0719457":{"_id":"y1eaaf1fe0719457","component":"_Channel","state":"$editorUpdateComponentId","action":"function $editorUpdateComponentId(oldId, newId) { \n this.require('factory').updateComponentId(oldId, newId);\n\n this.require('designer').save();\n \n this.require('workspace').render();\t\t\n}","useCoreAPI":false,"core":false},"w1875419b271fb1c":{"_id":"w1875419b271fb1c","component":"Designer","state":"addShorcuts","action":"function addShorcuts() {\n if (this.isMac()) {\n document.body.addEventListener('keydown', function keydown(event) {\n var message = this.require('message'),\n key = event.which || event.keyCode,\n command = event.metaKey ? event.metaKey : ((key === 91) ? true : false),\n dialog = null,\n Dialog = null,\n position = 0;\n\n switch (true) {\n // Command + O\n case key === 79 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({ 'title': '' });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + F\n case key === 70 && command:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + '+'\n case (key === 187 || key === 43) && command:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + I\n case key === 73 && command:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n\n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + E\n case key === 69 && command && !this.isCordova():\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ->\n case key === 39 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + <-\n case key === 37 && command:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length - 1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + v\n case key === 40 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + ^\n case key === 38 && command:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + Enter\n case key === 13 && command:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Enter \n case key === 13 && !command:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Command + D\n case key === 68 && command && !this.isCordova():\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n } else {\n document.body.addEventListener('keydown', function keydown(event) {\n var message = this.require('message'),\n key = event.which || event.keyCode,\n ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false);\n dialog = null,\n Dialog = null;\n\n switch (true) {\n // Ctrl + O\n case key === 79 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogCommand');\n dialog = new Dialog({ 'title': '' });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + F\n case key === 70 && ctrl:\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = runtime.require('DialogSearch');\n dialog = new Dialog({\n 'title': 'Search in the system',\n });\n dialog.show();\n } else {\n message.warning('There is no system.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + '+' \n case (key === 187 || key === 43) && ctrl:\n if (!this.require('factory').system() && this.require('state').menu() !== 'systems') {\n message.warning('There is no system: create first a system to continue.');\n } else {\n if (this.require('factory').system() && Object.keys(this.require('factory').system().schemas()).length === 0 && this.require('state').menu() === 'components') {\n message.warning('There is no schema: create first a schema to continue.');\n } else {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n this.require('workspace').create();\n }\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + I\n case key === 73 && ctrl:\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n var DialogImportFile = this.require('DialogImportFile');\n\n DialogImportFile = new DialogImportFile({\n 'title': 'Import a system'\n });\n DialogImportFile.show();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + E\n case key === 69 && ctrl && !this.isCordova():\n if (this.require('factory').system()) {\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n Dialog = this.require('DialogExport');\n dialog = new Dialog({\n 'title': 'Export the current system',\n });\n dialog.show();\n } else {\n message.warning('There is no system to export.');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ->\n case key === 39 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().menu().length) {\n position = 0;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + <-\n case key === 37 && ctrl:\n position = this.require('state').navigation().menu().indexOf('designer-menu-item-' + this.require('state').menu());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().menu().length - 1;\n }\n document.getElementById(this.require('state').navigation().menu(position)).click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + v\n case key === 40 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position + 1;\n if (position === this.require('state').navigation().spaces().length) {\n position = 0;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + ^\n case key === 38 && ctrl:\n position = this.require('state').navigation().spaces().indexOf('designer-space-' + this.require('state').space());\n if (position !== -1) {\n position = position - 1;\n if (position === -1) {\n position = this.require('state').navigation().spaces().length - 1;\n }\n $('#' + this.require('state').navigation().spaces(position)).children()[0].click();\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + Enter\n case key === 13 && ctrl:\n this.require('13f70137b61b19b').click();\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Enter \n case key === 13 && !ctrl:\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n // Ctrl + D\n case key === 68 && ctrl && !this.isCordova():\n if (this.require('factory').system()) {\n this.require('designer').open('diagram.html#' + this.require('factory').system().id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n event.stopPropagation();\n event.preventDefault();\n return false;\n break;\n default:\n break;\n }\n }.bind(this));\n }\n\n}","useCoreAPI":false,"core":false},"q1e05f1c28c13d04":{"_id":"q1e05f1c28c13d04","component":"Designer","state":"runMessages","action":"function runMessages(messages) { \n messages.forEach(function (message) {\n if (message && message.event && message.event.indexOf('$system') === -1) {\n $db._Message.insert(message);\n }\n });\t\n}","useCoreAPI":true,"core":false},"c107c51c3091756f":{"_id":"c107c51c3091756f","component":"o195831c8251b34e","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\n}","useCoreAPI":false,"core":false},"v173801bd85122c0":{"_id":"v173801bd85122c0","component":"t1bcd213629187e0","state":"click","action":"function click() { \n $('#designer-toolbar-item-diagram').tooltip('hide');\n if ($('#designer-dialog').children().length) {\n $('#' + $(\"#designer-dialog\").children()[0].id).removeClass('fade').modal('hide');\n }\n \n var system = this.require('factory').system();\n \n if (system && system.name() !== 'default') {\n this.require('designer').open('diagram.html#' + system.id(), 'diagram-' + this.require('factory').system().id());\n } else {\n this.require('designer').open('diagram.html#', 'diagram-0');\n }\t\n}","useCoreAPI":false,"core":false},"d1128a15dc117e6f":{"_id":"d1128a15dc117e6f","component":"j1b4981736918b41","state":"click","action":"function click() { \n window.history.back();\t\n}","useCoreAPI":false,"core":false},"t114671df7c16805":{"_id":"t114671df7c16805","component":"u18d911723019b96","state":"click","action":"function click() { \n window.history.forward();\n}","useCoreAPI":false,"core":false}},"types":{"dialogtype":{"_id":"i1947115bed161d4","name":"dialogtype","type":"string","value":["sync","system","type","schema","model","behavior","component"]},"editorType":{"_id":"o1d8851841b1c785","name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component","diagram"]},"editorRuntimeType":{"name":"editorRuntimeType","type":"string","value":["ace","codemirror"]},"editorRef":{"name":"editorRef","type":"object"},"language":{"_id":"z19c6b10ed914764","name":"language","type":"any","value":["javascript"]},"navigation":{"_id":"n1bb7e1a8a713f75","name":"navigation","type":"object","schema":{"menu":{"type":"array","mandatory":false,"default":[]},"spaces":{"type":"array","mandatory":false,"default":[]}}},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"_Channel":{"channel":{"_id":"channel"}},"Designer":{"designer":{"_id":"designer","debugWindow":null,"runWindow":null,"version":"3.5.3"}},"Diagram":{},"Export":{"export":{"_id":"export"}},"Extension":{"w15b291d1a312ff6":{"_id":"w15b291d1a312ff6","installed":false,"isCore":true,"source":{"name":"extension-model-json","master":false,"version":"1.5.0","description":"Create a model from a JSON file","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"type":"number","readOnly":false,"mandatory":false,"default":100},"type":{"type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{},"click":{},"platform":{"type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{},"hide":{},"cancel":{},"ok":{},"render":{}}},"behaviors":{"z1f6731cf3219889":{"_id":"z1f6731cf3219889","component":"x10b021de0a19b46","state":"click","action":"function click() { \n $('#designer-toolbar-item-model-json').tooltip('hide');\n \n if (this.require('factory').system()) {\n this.require('j16a581f46813de3').render();\n } else {\n this.require('message').warning('There is no system');\n } \n}","useCoreAPI":false,"core":false},"v19bb01b70a1a51c":{"_id":"v19bb01b70a1a51c","component":"j16a581f46813de3","state":"ok","action":"function ok() {\n var name = $('#modal-modeljson-name').val(),\n jsonText = $('#modal-modeljson-json').val(),\n json = null,\n schema = {},\n model = {},\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n that = this,\n createdTypes = [];\n\n function _cleanName(name) {\n var cleanedName = name.replace(/\\-/gi,'_');\n \n if (name && '0123456789'.indexOf(name[0]) !== -1) { \n cleanedName = '_' + cleanedName; \n }\n \n return cleanedName;\n }\n\n function _mergeItems(arr) {\n var result = {};\n\n arr.forEach(function forEach(item) {\n var copyItem = {},\n prop = '',\n subprop = '';\n\n for (prop in item) {\n switch (_getType(item[prop])) {\n case 'object':\n for (subprop in item[prop]) {\n if (typeof result[prop] === 'undefined') {\n result[prop] = {};\n }\n result[prop][subprop] = item[prop][subprop];\n }\n break;\n case 'array':\n if (typeof result[prop] === 'undefined') {\n result[prop] = [];\n }\n item[prop].forEach(function (val) {\n result[prop].push(val);\n });\n break;\n default:\n result[prop] = item[prop];\n break;\n }\n }\n });\n\n return result;\n }\n\n function _getTypeName(parent, name) {\n var result = '';\n \n if (!_validType(name)) {\n result = _cleanName(name) + '_' + Math.floor(Math.random() * 11);\n } else {\n result = _cleanName(name);\n }\n\n return result;\n }\n\n function _getType(value) {\n var type = '';\n\n if (Array.isArray(value)) {\n type = 'array';\n } else {\n type = typeof value;\n }\n\n return type;\n }\n\n function _validName(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().schemas()) {\n if (that.require('factory').system().schemas()[id]._name === name) {\n result = false;\n break;\n }\n }\n\n if (that.require('factory').system().name() === name) {\n result = false;\n }\n\n return result;\n }\n\n // comment the code \n // to have less types\n // but possible type collisions\n function _validType(name) {\n var result = true,\n id = '';\n\n for (id in that.require('factory').system().types()) {\n if (that.require('factory').system().types()[id].name === name) {\n result = false;\n break;\n }\n }\n\n if (createdTypes.indexOf(name) !== -1) {\n result = false;\n }\n \n\n return result;\n }\n\n function _createTypeFromObject(parent, name, obj) {\n var typeDef = '',\n property = '',\n type = '',\n typeName = '',\n arrayType = '',\n cleanProperty = '';\n\n typeName = _getTypeName(parent, name);\n typeDef = that.require('factory').addType(typeName, false);\n createdTypes.push(typeName);\n\n typeDef.schema = {};\n that.require('designer').save();\n\n for (property in obj) {\n //if (property.indexOf('_') !== 0) {\n type = _getType(obj[property]);\n cleanProperty = _cleanName(property);\n switch (type) {\n case 'object':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = _createTypeFromObject(name, property, obj[property]);\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = {};\n break;\n case 'number':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'number';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = 0;\n break;\n case 'boolean':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'boolean';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = false;\n break;\n case 'array':\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].mandatory = false;\n if (typeof obj[property][0] !== 'undefined') {\n arrayType = _getType(obj[property][0]);\n\n if (arrayType === 'object') {\n if (obj[property][0] !== null) {\n typeDef.schema[cleanProperty].type = [_createTypeFromObject(name, property, _mergeItems(obj[property]))];\n typeDef.schema[cleanProperty].default = [];\n } else {\n typeDef.schema[cleanProperty].type = ['object'];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = [arrayType];\n typeDef.schema[cleanProperty].default = [];\n }\n } else {\n typeDef.schema[cleanProperty].type = ['any'];\n typeDef.schema[cleanProperty].default = [];\n }\n break;\n default:\n typeDef.schema[cleanProperty] = {};\n typeDef.schema[cleanProperty].type = 'string';\n typeDef.schema[cleanProperty].mandatory = false;\n typeDef.schema[cleanProperty].default = '';\n break;\n }\n //}\n }\n that.require('factory').updateType(typeName, typeDef);\n that.require('designer').save();\n\n return typeName;\n }\n\n // clean name\n name = name.replace(/\\s|\\t/gi, '_').replace(/[\\-\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~]/gi, '');\n\n if (name && _validName(name) && jsonText) {\n try {\n json = JSON.parse(jsonText);\n if (json) {\n // schema\n schema = this.require('factory').addSchema(name.trim());\n\n schema._inherit = [];\n this.require('factory').updateSchema(schema._id, schema);\n\n this.require('designer').save();\n\n for (property in json) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n if (type === 'array') {\n schema[property] = 'collection';\n } else {\n schema[property] = 'property';\n }\n }\n }\n\n this.require('factory').updateSchema(schema._id, schema);\n this.require('designer').save();\n\n // model\n model = this.require('factory').createModel(schema);\n this.require('designer').save();\n\n for (property in schema) {\n if (property.indexOf('_') !== 0) {\n type = _getType(json[property]);\n switch (type) {\n case 'object':\n if (json[property] !== null) {\n model[property].type = _createTypeFromObject('', property, json[property]);\n model[property].default = {};\n } else {\n model[property].type = 'object';\n model[property].default = {};\n }\n break;\n case 'number':\n model[property].type = 'number';\n model[property].default = 0;\n break;\n case 'boolean':\n model[property].type = 'boolean';\n model[property].default = false;\n break;\n case 'array':\n if (typeof json[property][0] !== 'undefined') {\n arrayType = _getType(json[property][0]);\n if (arrayType === 'object') {\n if (json[property][0] !== null) {\n model[property].type = [_createTypeFromObject('', property, _mergeItems(json[property]))];\n model[property].default = [];\n } else {\n model[property].type = ['object'];\n model[property].default = [];\n }\n } else {\n model[property].type = [arrayType];\n model[property].default = [];\n }\n } else {\n model[property].type = ['any'];\n model[property].default = [];\n }\n break;\n case 'string':\n model[property].type = 'string';\n model[property].default = '';\n break;\n default:\n break;\n }\n }\n }\n\n this.require('factory').updateModel(model._id, model);\n this.require('designer').save();\n\n this.require('channel').$designerCreateSchema(name, schema);\n\n this.hide();\n\n this.require('spaces').render();\n this.require('workspace').render();\n\n this.require('message').success('A model has been created for the JSON.');\n }\n } catch (e) {\n this.hide();\n this.require('message').warning('Can not create the model: the JSON is invalid.');\n }\n }\n}","useCoreAPI":false,"core":false},"h19d481534915d09":{"_id":"h19d481534915d09","component":"j16a581f46813de3","state":"render","action":"function render() { \n var dom = null;\n \n this.require('Modal').render(this);\t\n \n $('#modal-modeljson').on('shown.bs.modal', function modal() {\n $('#modal-modeljson-name').focus();\n });\n \n // events\n dom = document.getElementById('modal-modeljson-name');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-name').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n \n dom = document.getElementById('modal-modeljson-json');\n dom.addEventListener('keyup', function keyup(event) {\n if (event.keyCode === 13) {\n event.stopPropagation();\n event.preventDefault();\n if ($('#modal-modeljson-json').val()) {\n this.ok();\n }\n return false;\n }\n }.bind(this));\n}","useCoreAPI":false,"core":false},"h1f7551398814e9b":{"_id":"h1f7551398814e9b","component":"j16a581f46813de3","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"v16701182a014b42":{"_id":"v16701182a014b42","component":"Modal","state":"render","action":"function render() { \n var html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"x1902b11a0a1b7d8":{"_id":"x1902b11a0a1b7d8","component":"Modal","state":"hide","action":"function hide() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"x16db81674e14726":{"_id":"x16db81674e14726","component":"Modal","state":"show","action":"function show() { \n var id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"x10b021de0a19b46":{"_id":"x10b021de0a19b46","html":"toolbar-item-modeljson.html","platform":"all","position":68,"type":"designer"}},"HTML":{"modal-modeljson.html":{"_id":"modal-modeljson.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \t\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"toolbar-item-modeljson.html":{"_id":"toolbar-item-modeljson.html","source":""}},"Modal":{"j16a581f46813de3":{"_id":"j16a581f46813de3","html":"modal-modeljson.html","message":"","title":"Create a model from JSON"}}},"_id":"u155371124418bea"}}},"Github":{"github":{"_id":"github"}},"HTML":{"copyright.html":{"_id":"copyright.html","source":"Version {{version}}
    Copyright © 2019 - Erwan Carriou

    System\nDesigner is distributed under Apache License 2.0 and is powered by System Runtime.

    For comments or questions\nyou can go to the support page or send me an email.
    If you find a bug, please\nreport it on this page."},"dialog-modal-welcome.html":{"_id":"dialog-modal-welcome.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n System Designer will help you to create systems. To begin have a look on our\n Quick Start page or at this short video:\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n"},"menu-action-version.html":{"_id":"menu-action-version.html","source":"v3.5.3"},"menu-header-behavior.html":{"_id":"menu-header-behavior.html","source":"
    "},"menu-header-component.html":{"_id":"menu-header-component.html","source":"
    "},"menu-header-model.html":{"_id":"menu-header-model.html","source":"
    "},"menu-header-schema.html":{"_id":"menu-header-schema.html","source":"
    "},"menu-header-system.html":{"_id":"menu-header-system.html","source":"
    "},"menu-header-type.html":{"_id":"menu-header-type.html","source":"
    "},"model-behavior.html":{"_id":"model-behavior.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
    {{content}}
    \n
    \n
    \n
    "},"model-class.html":{"_id":"model-class.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
      \n {{attributes}}\n
    • \n {{methods}}\n
    \n
    \n
    \n
    \n
    "},"model-component.html":{"_id":"model-component.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-log.html":{"_id":"model-log.html","source":"
    \n
    \n
    \n

    Logs

    \n
    \n \n
    \n
    \n
    \n
    \n {{logs}}\n
    \n
    \n
    \n
    "},"model-schema.html":{"_id":"model-schema.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    \n
    "},"model-system.html":{"_id":"model-system.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n \n \n \n \n {{content}}\n \n
    \n
    \n
    \n
    "},"model-type.html":{"_id":"model-type.html","source":"
    \n
    \n
    \n

    {{title}}

    \n
    \n \n
    \n
    \n
    \n
      \n {{content}}\n
    \n
    \n
    \n
    "},"dialog-modal-behavior-creation.html":{"_id":"dialog-modal-behavior-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-creation.html":{"_id":"dialog-modal-component-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-config.html":{"_id":"dialog-modal-config.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n\n\n"},"dialog-modal-copyright.html":{"_id":"dialog-modal-copyright.html","source":""},"dialog-modal-drop-file.html":{"_id":"dialog-modal-drop-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-export.html":{"_id":"dialog-modal-export.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import-file.html":{"_id":"dialog-modal-import-file.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{library}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-import.html":{"_id":"dialog-modal-import.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-model-creation.html":{"_id":"dialog-modal-model-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    You can not directly create a model.

    \n

    To create a model, you have to create a schema and then a model will be generated based on your schema definition.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-component-info.html":{"_id":"dialog-modal-component-info.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n

    By default all your models inherit from _Component. It adds to your models a set of APIs to:

    \n

    - manage your components,

    \n

    - add/remove listeners to components events and

    \n

    - require components.

    \n

    You can remove this inheritance for your needs.

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-schema-creation.html":{"_id":"dialog-modal-schema-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-search.html":{"_id":"dialog-modal-search.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n
    \n Search for\n \n
    \n
    \n
    \n
    \n
    \n

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "},"dialog-modal-share.html":{"_id":"dialog-modal-share.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-sync.html":{"_id":"dialog-modal-sync.html","source":"
    \n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    {{title}}

    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n
    "},"dialog-modal-system-creation.html":{"_id":"dialog-modal-system-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-type-creation.html":{"_id":"dialog-modal-type-creation.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"dialog-modal.html":{"_id":"dialog-modal.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"export-app-github.html":{"_id":"export-app-github.html","source":"\n\n\n\n {{name}}\n \n \n \n \n\n\n\n \n \n\n\n"},"export-app.html":{"_id":"export-app.html","source":"\n\n\n\n {{name}}\n \n \n\n\n\n \n \n \n \n\n\n"},"help-behaviors.html":{"_id":"help-behaviors.html","source":"{help_behaviors}"},"help-components.html":{"_id":"help-components.html","source":"{help_components}"},"help-logs.html":{"_id":"help-logs.html","source":"{help_logs}"},"help-models.html":{"_id":"help-models.html","source":"{help_models}"},"help-schemas.html":{"_id":"help-schemas.html","source":"{help_schemas}"},"help-system.html":{"_id":"help-system.html","source":"{help_systems}"},"help-types.html":{"_id":"help-types.html","source":"{help_types}"},"menu-header.html":{"_id":"menu-header.html","source":"
    "},"menu-item-action.html":{"_id":"menu-item-action.html","source":"Action"},"menu-item-behaviors.html":{"_id":"menu-item-behaviors.html","source":"Behaviors"},"menu-item-component.html":{"_id":"menu-item-component.html","source":"Component"},"menu-item-components.html":{"_id":"menu-item-components.html","source":"Components"},"menu-item-description.html":{"_id":"menu-item-description.html","source":"Description"},"menu-item-json.html":{"_id":"menu-item-json.html","source":"JSON"},"menu-item-logs.html":{"_id":"menu-item-logs.html","source":"Logs0"},"menu-item-model.html":{"_id":"menu-item-model.html","source":"Model"},"menu-item-models.html":{"_id":"menu-item-models.html","source":"Models"},"menu-item-mson.html":{"_id":"menu-item-mson.html","source":"MSON"},"menu-item-name.html":{"_id":"menu-item-name.html","source":"Name"},"menu-item-overview.html":{"_id":"menu-item-overview.html","source":"Overview"},"menu-item-schema.html":{"_id":"menu-item-schema.html","source":"Schema"},"menu-item-schemas.html":{"_id":"menu-item-schemas.html","source":"Schemas"},"menu-item-system.html":{"_id":"menu-item-system.html","source":"Systems"},"menu-item-type.html":{"_id":"menu-item-type.html","source":"Type"},"menu-item-types.html":{"_id":"menu-item-types.html","source":"Types"},"menu-item-version.html":{"_id":"menu-item-version.html","source":"Version"},"message-alert-danger.html":{"_id":"message-alert-danger.html","source":"
    {{message}}
    "},"message-alert-info.html":{"_id":"message-alert-info.html","source":"
    {{message}}
    "},"message-alert-success.html":{"_id":"message-alert-success.html","source":"
    {{message}}
    "},"message-alert-warning.html":{"_id":"message-alert-warning.html","source":"
    {{message}}
    "},"toolbar-item-config.html":{"_id":"toolbar-item-config.html","source":""},"toolbar-item-copy.html":{"_id":"toolbar-item-copy.html","source":""},"toolbar-item-copyright.html":{"_id":"toolbar-item-copyright.html","source":""},"toolbar-item-create.html":{"_id":"toolbar-item-create.html","source":""},"toolbar-item-delete.html":{"_id":"toolbar-item-delete.html","source":""},"toolbar-item-export-document.html":{"_id":"toolbar-item-export-document.html","source":""},"toolbar-item-export.html":{"_id":"toolbar-item-export.html","source":""},"toolbar-item-help.html":{"_id":"toolbar-item-help.html","source":""},"toolbar-item-import.html":{"_id":"toolbar-item-import.html","source":""},"toolbar-item-library.html":{"_id":"toolbar-item-library.html","source":""},"toolbar-item-paste.html":{"_id":"toolbar-item-paste.html","source":""},"toolbar-item-publish.html":{"_id":"toolbar-item-publish.html","source":""},"toolbar-item-redo.html":{"_id":"toolbar-item-redo.html","source":""},"toolbar-item-refresh.html":{"_id":"toolbar-item-refresh.html","source":""},"toolbar-item-save.html":{"_id":"toolbar-item-save.html","source":""},"toolbar-item-search.html":{"_id":"toolbar-item-search.html","source":""},"toolbar-item-select-all.html":{"_id":"toolbar-item-select-all.html","source":""},"toolbar-item-share.html":{"_id":"toolbar-item-share.html","source":""},"toolbar-item-sync.html":{"_id":"toolbar-item-sync.html","source":""},"toolbar-item-undo.html":{"_id":"toolbar-item-undo.html","source":""},"toolbar-item-extension.html":{"_id":"toolbar-item-extension.html","source":""},"dialog-modal-extension.html":{"_id":"dialog-modal-extension.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{uninstalled_extensions}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{systems}}\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n {{extensions}}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    "},"dialog-modal-command.html":{"_id":"dialog-modal-command.html","source":"
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n Open\n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "},"toolbar-item-command.html":{"_id":"toolbar-item-command.html","source":""},"dialog-modal-delete.html":{"_id":"dialog-modal-delete.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"message-help.html":{"_id":"message-help.html","source":"
    \n
    \n {{message}} \n
    \n
    "},"menu-item-bundle.html":{"_id":"menu-item-bundle.html","source":"Bundle"},"menu-item-behavior.html":{"_id":"menu-item-behavior.html","source":"Behavior"},"toolbar-item-diagram.html":{"_id":"toolbar-item-diagram.html","source":""},"toolbar-item-zoomout.html":{"_id":"toolbar-item-zoomout.html","source":""},"toolbar-item-zoomin.html":{"_id":"toolbar-item-zoomin.html","source":""},"toolbar-item-zoominit.html":{"_id":"toolbar-item-zoominit.html","source":""},"toolbar-item-export-diagram.html":{"_id":"toolbar-item-export-diagram.html","source":""},"menu-action-back.html":{"_id":"menu-action-back.html","source":""},"menu-action-forward.html":{"_id":"menu-action-forward.html","source":""},"dialog-modal-drop-diagram.html":{"_id":"dialog-modal-drop-diagram.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "},"menu-item-class-diagram.html":{"_id":"menu-item-class-diagram.html","source":"Class diagram"},"menu-item-component-diagram.html":{"_id":"menu-item-component-diagram.html","source":"Component diagram"},"menu-item-graph-diagram.html":{"_id":"menu-item-graph-diagram.html","source":"Graph diagram"},"dialog-modal-install-pwa.html":{"_id":"dialog-modal-install-pwa.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n Because System Designer is a Progressive Web App (PWA), it can be installed on your device.
    \n
    \n Do you want to add System Designer to your Home Screen?\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Internationalization":{"i18n":{"_id":"i18n","locale":"en-US"}},"Strings":{"en-US":{"_id":"en-US","help_systems":"An application is a system. Once you have created one, your next step is to create a schema.","help_schemas":"A schema is the definition of your model. Models are generated based on the schema definition.","help_models":"A model is an UML representation of your classes. It is generated from a schema.","help_types":"A type is used in your model to define an enumeration or a structure.","help_behaviors":"A behavior is the action to do when a method or an event is called.","help_components":"Components are your classes instances. Their states are saved in a store, a JSON object.","help_logs":"You will find here the logs of the running system.

    Example of code to send a log:

    this
    .require('logger')
    .info('hello world');
    "}},"JS":{"app-github.js":{"_id":"app-github.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"app.js":{"_id":"app.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @module {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// install System Runtime\nconst runtime = require('system-runtime');\n\n// uncomment this line to debug your system\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\n// set the level of log\nruntime.require('logger').level('{{logLevel}}');\n\n// install and start the system\nruntime.install({{system}});"},"javascript-export.js":{"_id":"javascript-export.js","source":"/* \n * {{name}}\n * \n * @description {{description}}\n * \n * @system {{name}}\n * @version {{version}}\n * @requires system-runtime\n * \n */\n\n// uncomment this line if this system runs on node.js\n// const runtime = require('system-runtime');\n\n// uncomment this line to debug your system on node.js\n// runtime.install('node_modules/system-runtime/extensions/mode-admin-server.json');\n\nruntime.require('logger').level('{{logLevel}}');\n\n"}},"JSON":{"00-quickstart":{"_id":"00-quickstart","platform":"all","source":{"name":"quick-start","master":true,"version":"1.5.0","description":"Quick start\n\nThis system is taken from the quick start.","schemas":{"154661fa5617782":{"_id":"154661fa5617782","_name":"Jedi","_inherit":["_Component"],"firstName":"property","lastName":"property","father":"link","fullName":"method"}},"models":{"1a3a2150b31c099":{"_id":"1a3a2150b31c099","_name":"Jedi","firstName":{"description":"first name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"lastName":{"description":"last name of a Jedi","type":"string","readOnly":false,"mandatory":true,"default":""},"father":{"description":"father of a Jedi","type":"Jedi","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of a Jedi","result":"string"}}},"behaviors":{"137491d3c61213b":{"_id":"137491d3c61213b","component":"100e51f87218a8f","state":"start","action":"function start() {\n let luke = null,\n logger = null;\n \n // get logger component\n logger = this.require('logger');\n \n // get luke component\n luke = this.require('luke');\n \n // get the name of the father of Luke\n logger.info(luke.father().fullName());\n}","useCoreAPI":false,"core":false},"11a2910bbd142e1":{"_id":"11a2910bbd142e1","component":"Jedi","state":"fullName","action":"function fullName() {\n const result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Jedi":{"vader":{"_id":"vader","father":"","firstName":"Darth","lastName":"Vader"},"luke":{"_id":"luke","father":"vader","firstName":"Luke","lastName":"Skywalker"}}},"_id":"100e51f87218a8f"}},"01-book-collection":{"_id":"01-book-collection","platform":"all","source":{"name":"book-collection","master":true,"version":"1.5.0","description":"Create a Book collection manager\n\nThis system shows a list of books and an input to filter on that list.\n\nnote: if you create a Book Component when running the application, the list will be automatically updated","schemas":{"z198ba11ccf1a29b":{"_id":"z198ba11ccf1a29b","_name":"Template","_inherit":["_Component"],"source":"property","render":"method"},"l1f8dd1f44d1ef53":{"_id":"l1f8dd1f44d1ef53","_name":"CSS","_inherit":["_Component"],"source":"property","render":"method"},"l1cbef1eb531773c":{"_id":"l1cbef1eb531773c","_name":"List","_inherit":["_Component"],"filter":"property","render":"method"},"j1ca8314c081d9de":{"_id":"j1ca8314c081d9de","_name":"Book","_inherit":["_Component"],"name":"property","year":"property","author":"link"},"k1d43e1430e1af90":{"_id":"k1d43e1430e1af90","_name":"Author","_inherit":["_Component"],"firstName":"property","lastName":"property","fullName":"method"}},"models":{"o19b04191b513cf7":{"_id":"o19b04191b513cf7","_name":"Template","source":{"description":"html of the template","type":"html","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the template","params":[{"name":"elt","type":"DOMElement","mandatory":false,"default":null}]}},"z128c91df861dc34":{"_id":"z128c91df861dc34","_name":"CSS","source":{"description":"css of the component","type":"css","readOnly":false,"mandatory":false,"default":""},"render":{"description":"render the component"}},"p1b9fa10ca51e9d4":{"_id":"p1b9fa10ca51e9d4","_name":"List","render":{"description":"render the list"},"filter":{"description":"filter on the list","type":"string","readOnly":false,"mandatory":false,"default":"{}"}},"o18b681c27f196a6":{"_id":"o18b681c27f196a6","_name":"Book","_description":"","name":{"description":"name of a book","type":"string","readOnly":false,"mandatory":false,"default":""},"year":{"description":"year when the book was written","type":"number","readOnly":false,"mandatory":false,"default":0},"author":{"description":"author of the book","type":"Author","readOnly":false,"mandatory":false,"default":""}},"z174c61a72c16e21":{"_id":"z174c61a72c16e21","_name":"Author","_description":"","firstName":{"description":"first name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"lastName":{"description":"last name of an author","type":"string","readOnly":false,"mandatory":false,"default":""},"fullName":{"description":"full name of an author","params":[],"result":"string"}}},"behaviors":{"r1e7a2121b21dd77":{"_id":"r1e7a2121b21dd77","component":"k119f317c9d181db","state":"start","action":"function start() { \n // add HTML\n this.require('template').render();\n \n // add CSS\n this.require('list.css').render();\n \n // init the filter\n this.require('list').filter('');\n \n // show the list\n this.require('list').render();\n \n // add listener\n document.getElementById('search').addEventListener('keyup', function keyup(e) {\n this.require('list').filter(e.target.value.trim());\n }.bind(this));\n}","useCoreAPI":false,"core":false},"n1ab81101b41b375":{"_id":"n1ab81101b41b375","component":"Template","state":"render","action":"function render(elt) { \n let html = this.source(),\n domNode = elt;\n \n if (html) {\n if (domNode === null) {\n domNode = document.body;\n }\n \n domNode.insertAdjacentHTML('beforeend', html);\n }\n}","useCoreAPI":false,"core":false},"g1725a1c65e1d149":{"_id":"g1725a1c65e1d149","component":"CSS","state":"render","action":"function render() { \n let div = document.createElement('style');\n div.innerHTML = this.source();\n document.head.appendChild(div);\n}","useCoreAPI":false,"core":false},"k1d4551afd717da8":{"_id":"k1d4551afd717da8","component":"List","state":"render","action":"function render() { \n let items = [],\n properties = {},\n links = {},\n html = '',\n criteria = null,\n table = document.getElementById('table');\n \n if (table) {\n \n // get data\n if (this.filter().trim() !== '') {\n criteria = new RegExp(this.filter().trim(), 'gi');\n items = this.require('db').collections().Book.find({\n name: criteria\n });\n } else {\n items = this.require('db').collections().Book.find();\n }\n \n properties = this.require('Book').classInfo().properties();\n links = this.require('Book').classInfo().links();\n \n html = '';\n // build table header\n properties.forEach(function(property) {\n html = html + '' + property.toUpperCase() +''; \n });\n links.forEach(function (link) {\n html = html + '' + link.toUpperCase() +''; \n });\n html = html + '';\n \n // build table body\n items.forEach(function (item){\n html = html + '';\n \n properties.forEach(function(property) {\n html = html + '' + item[property] + '';\n });\n \n links.forEach(function (link) {\n const author = this.require(item[link]);\n \n if (author) {\n html = html + '' + author.fullName() + '';\n } else {\n html = html + '';\n }\n }.bind(this));\n \n html = html + '';\n }.bind(this));\n \n html = html + '';\n \n table.innerHTML = html;\n }\n}","useCoreAPI":false,"core":false},"w1d4ac1c9821d391":{"_id":"w1d4ac1c9821d391","component":"List","state":"filter","action":"function filter(value) { \n\tthis.render();\n}","useCoreAPI":false,"core":false},"a1a55019f6a116d1":{"_id":"a1a55019f6a116d1","component":"Book","state":"init","action":"function init(conf) { \n this.require('list').render();\t\n}","useCoreAPI":false,"core":false},"s106991b9f112c56":{"_id":"s106991b9f112c56","component":"Book","state":"destroy","action":"function destroy() { \n this.require('list').render();\n\n // destroy the component\n $component.destroy(this.id());\n}","useCoreAPI":true,"core":false},"o1d3ca175e51c17b":{"_id":"o1d3ca175e51c17b","component":"Author","state":"fullName","action":"function fullName() { \n let result = this.firstName() + ' ' + this.lastName();\n return result;\n}","useCoreAPI":false,"core":false}},"types":{"DOMElement":{"_id":"m14b771764815eca","name":"DOMElement","type":"object"}},"components":{"CSS":{"list.css":{"_id":"list.css","source":"body {\n padding-top: 50px;\n font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n}\n\n.input-group {\n padding-bottom:20px;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 100%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: left;\n padding: 8px;\n}\n\nth {\n background-color: #e7e7e7;\n}"}},"Template":{"template":{"_id":"template","source":"
    \n \n
    \n\n
    "}},"List":{"list":{"_id":"list","filter":""}},"Book":{"n193a61759c1003b":{"_id":"n193a61759c1003b","author":"p183d91088f12f6a","name":"The Three Musketeers","year":1844},"v1ff7018f18166da":{"_id":"v1ff7018f18166da","author":"a1654216c6c11216","name":"Twenty Thousand Leagues Under the Sea","year":1870},"g138f61067815e83":{"_id":"g138f61067815e83","author":"r1ee7f1534e19b8b","name":"The Little Prince","year":1943}},"Author":{"r1ee7f1534e19b8b":{"_id":"r1ee7f1534e19b8b","firstName":"Antoine","lastName":"De Saint-Exupéry"},"a1654216c6c11216":{"_id":"a1654216c6c11216","firstName":"Jules","lastName":"Verne"},"p183d91088f12f6a":{"_id":"p183d91088f12f6a","firstName":"Alexandre","lastName":"Dumas"}}},"_id":"k119f317c9d181db"}},"02-nodejs":{"_id":"02-nodejs","platform":"electron","source":{"name":"nodejs","master":true,"version":"1.5.0","description":"Create a server application\n\nThis example shows you how to create a Node.js application in System Designer.\n\nYou can the test the application directly in System Designer.","schemas":{},"models":{},"behaviors":{"17d001e5ae12a44":{"_id":"17d001e5ae12a44","component":"1638e12721115b5","state":"start","action":"function start() { \n const http = require('http'),\n logger = this.require('logger');\n\n http.createServer(function (req, res) {\n res.writeHead(200);\n res.end('hello world\\n');\n }).listen(1234);\n \n logger.info('server is running at http://127.0.0.1:1234');\n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"1638e12721115b5"}},"03-graph-system-example":{"_id":"03-graph-system-example","platform":"all","source":{"name":"graph-example","master":true,"version":"1.0.0","description":"Graph system example. \n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"},"n1a88c10eff1beb6":{"_id":"n1a88c10eff1beb6","_name":"Person","_inherit":["Nodes"],"name":"property","age":"property"},"z1747d12e621e92f":{"_id":"z1747d12e621e92f","_name":"IS_FRIEND_WITH","_inherit":["Relationships"],"since":"property"},"i15a3614c1e17109":{"_id":"i15a3614c1e17109","_name":"HAS_READ","_inherit":["Relationships"],"date":"property","rated":"property"},"i1d8501332c1c6bd":{"_id":"i1d8501332c1c6bd","_name":"Book","_inherit":["Nodes"],"title":"property","author":"property"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"m11c1515b7e12099":{"_id":"m11c1515b7e12099","_name":"Person","_description":"","name":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"age":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0}},"g19e531c5c819149":{"_id":"g19e531c5c819149","_name":"IS_FRIEND_WITH","_description":"","since":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"d11f871f899154fd":{"_id":"d11f871f899154fd","_name":"HAS_READ","_description":"","date":{"description":"","type":"date","readOnly":false,"mandatory":false,"default":"1970-01-01T00:00:00.000Z"},"rated":{"description":"","type":"number","readOnly":false,"mandatory":false,"default":0},"incoming":{"description":"","type":"Person","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"","type":"Book","kind":"normal","readOnly":false,"mandatory":false,"default":""}},"y12eff155c715742":{"_id":"y12eff155c715742","_name":"Book","_description":"","title":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""},"author":{"description":"","type":"string","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b99d","state":"start","action":"function start() { \n // show the number of person that have read the book GraphDatabase\n this.require('logger').info(\n this.require('db').collections().HAS_READ.find({\n 'outgoing': {\n '$eq': 'GraphDatabase'\n }\n }).length\n );\n}","useCoreAPI":false,"core":false}},"types":{},"components":{"Person":{"sally":{"_id":"sally","age":32,"name":"Sally"},"john":{"_id":"john","age":27,"name":"John"}},"IS_FRIEND_WITH":{"i1c36e1b6331b0f6":{"_id":"i1c36e1b6331b0f6","incoming":"john","outgoing":"sally","since":"2013-01-09T00:00:00.000Z"}},"HAS_READ":{"k132a8124351e768":{"_id":"k132a8124351e768","date":"2013-02-03T00:00:00.000Z","incoming":"john","outgoing":"GraphDatabase","rated":5},"s146f0142a518868":{"_id":"s146f0142a518868","date":"2013-09-02T00:00:00.000Z","incoming":"sally","outgoing":"GraphDatabase","rated":4}},"Book":{"GraphDatabase":{"_id":"GraphDatabase","author":"Jim Webber, Ian Robinson","title":"Graph Database"}}},"_id":"c14393197831b99d"}},"04-create-graph-system":{"_id":"04-create-graph-system","platform":"all","source":{"name":"graph-system","master":true,"version":"1.1.0","description":"Create a Graph system.\n\nCreate a Graph system with models that inherit from Nodes and Relationships models.\n\n\nnote: see the tutorials for more informations.","schemas":{"q1fb6e179641acb7":{"_id":"q1fb6e179641acb7","_name":"Nodes","_inherit":["_Component"]},"q1a868198e31bce7":{"_id":"q1a868198e31bce7","_name":"Relationships","_inherit":["_Component"],"incoming":"link","outgoing":"link"}},"models":{"e143b513b801a48c":{"_id":"e143b513b801a48c","_name":"Nodes","_description":""},"l1bf6210e8510013":{"_id":"l1bf6210e8510013","_name":"Relationships","_description":"","incoming":{"description":"Nodes component that starts the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""},"outgoing":{"description":"Nodes component that ends the relationship","type":"Nodes","kind":"normal","readOnly":false,"mandatory":false,"default":""}}},"behaviors":{"k191b51f33413bc3":{"_id":"k191b51f33413bc3","component":"c14393197831b88d","state":"start","action":"function start() { \n \n}","useCoreAPI":false,"core":false}},"types":{},"components":{},"_id":"c14393197831b88d"}},"06-create-extension.json":{"_id":"06-create-extension.json","platform":"all","source":{"name":"extension-template","master":false,"version":"1.5.0","description":"Create an extension\n\nExtension for creating:\n\n* toolbar items,\n* actions when clicking on them and\n* show modal dialog.\n\n\nnote: see the tutorials for more informations.","schemas":{"p181111d5c01f97b":{"_id":"p181111d5c01f97b","_inherit":["_Component"],"_name":"HTML","render":"method","source":"property"},"t19b6b11ff31158d":{"_id":"t19b6b11ff31158d","_name":"ToolBarItem","_inherit":["_Component"],"html":"link","position":"property","type":"property","platform":"property","render":"method","click":"event"},"l1cbdc1fc4612ece":{"_id":"l1cbdc1fc4612ece","_name":"Modal","_inherit":["_Component"],"title":"property","message":"property","html":"link","ok":"event","cancel":"event","show":"method","hide":"method","render":"method"}},"models":{"w1417e1d6d613a0d":{"_id":"w1417e1d6d613a0d","_name":"HTML","source":{"description":"HTML of the component","type":"html","readOnly":true,"mandatory":true,"default":""},"render":{"description":"render the component","params":[{"name":"id","type":"any","mandatory":false,"default":null}]}},"u1f4c7177bb1a459":{"_id":"u1f4c7177bb1a459","_name":"ToolBarItem","html":{"description":"HTML the toolbar item","type":"HTML","readOnly":false,"mandatory":false,"default":"toolbar-item-template.html"},"position":{"description":"position of the toolbar item in the toolbar","type":"number","readOnly":false,"mandatory":false,"default":70},"type":{"description":"on which context to display the toolbar item","type":"editorType","readOnly":false,"mandatory":false,"default":"designer"},"render":{"description":"render the toolbar item"},"click":{"description":"click on the toolbar item"},"platform":{"description":"on which platform to display the toolbar item","type":"platform","readOnly":false,"mandatory":false,"default":"all"}},"q1d12b19f4712a7a":{"_id":"q1d12b19f4712a7a","_name":"Modal","title":{"description":"title of the modal","type":"text","readOnly":true,"mandatory":false,"default":""},"message":{"description":"message to display","type":"text","readOnly":true,"mandatory":false,"default":""},"html":{"description":"HTML of the modal","type":"HTML","readOnly":false,"mandatory":false,"default":"modal-template.html"},"show":{"description":"show the modal"},"hide":{"description":"hide the modal"},"cancel":{"description":"click on the 'Cancel' button of the modal"},"ok":{"description":"click on the 'OK' button of the modal"},"render":{"description":"render the modal"}}},"behaviors":{"g10c63191dc16341":{"_id":"g10c63191dc16341","component":"toolbar-item-template","state":"click","action":"function click() { \n $('#designer-toolbar-item-template').tooltip('hide');\n this.require('modal-template').render();\t\n}","useCoreAPI":false,"core":false},"d1bdde1f59f1befe":{"_id":"d1bdde1f59f1befe","component":"Modal","state":"show","action":"function show() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('show');\n}","useCoreAPI":false,"core":false},"n1467b1097a16481":{"_id":"n1467b1097a16481","component":"Modal","state":"hide","action":"function hide() { \n const id = this.html().id().replace('.html', '');\n $('#' + id).modal('hide');\n}","useCoreAPI":false,"core":false},"t1fb0b150c810528":{"_id":"t1fb0b150c810528","component":"Modal","state":"render","action":"function render() { \n let html = '',\n dom = null,\n templateId = this.html().id(),\n id = templateId.replace('.html', '');\n\n // empty area\n $('#designer-dialog').empty();\n\n // render\n html = this.html();\n document.querySelector('#designer-dialog').insertAdjacentHTML('afterbegin',\n html.source()\n .replace(/{{title}}/gi, this.title())\n .replace(/{{message}}/gi, this.message())\n );\n\n // modal events\n dom = document.getElementById(id + '-cancel');\n dom.addEventListener('click', function click(event) {\n this.cancel();\n }.bind(this));\n \n dom = document.getElementById(id + '-ok');\n dom.addEventListener('click', function click(event) {\n this.ok();\n }.bind(this));\t\t\n \n // show modal\n $('#' + id).modal('show');\t\n}","useCoreAPI":false,"core":false},"w1cffe198cb19e9c":{"_id":"w1cffe198cb19e9c","component":"modal-template","state":"cancel","action":"function cancel() { \n this.hide();\t\n}","useCoreAPI":false,"core":false},"c1bee91492f11173":{"_id":"c1bee91492f11173","component":"modal-template","state":"ok","action":"function ok() { \n this.hide();\t\n}","useCoreAPI":false,"core":false}},"types":{"editorType":{"name":"editorType","type":"string","value":["designer","system","type","schema","model","behavior","component"]},"platform":{"_id":"r10214160211309c","name":"platform","type":"string","value":["all","web","electron","cordova"]}},"components":{"ToolBarItem":{"toolbar-item-template":{"_id":"toolbar-item-template","html":"toolbar-item-template.html","platform":"all","position":70,"type":"designer"}},"HTML":{"toolbar-item-template.html":{"_id":"toolbar-item-template.html","source":""},"modal-template.html":{"_id":"modal-template.html","source":"
    \n
    \n
    \n
    \n

    {{title}}

    \n
    \n
    \n {{message}}\n
    \n
    \n \n \n
    \n
    \n
    \n
    "}},"Modal":{"modal-template":{"_id":"modal-template","message":"This is a template of a modal dialog.","title":"An example of modal dialog","html":"modal-template.html"}}},"_id":"h1ffb312ef619349"}},"07-listen-collection-events.json":{"_id":"07-listen-collection-events.json","source":{"name":"listen-collection-events","master":true,"version":"1.5.0","description":"Listen to components collection events\n\nSystem Runtime NoSQL Database is an instance of '_Database' class that sends insert, update and remove events for each collection of the database.\n\nYou can listen to all these events to perform the action you want.\n\nnote: events are send for the collections (i.e. schemas) you have created but also for the private collections of the database.\n\n\nnote: see the tutorials for more informations.","schemas":{"1723516a30132ac":{"_id":"1723516a30132ac","_name":"_Database","_inherit":["_Component"],"_core":true,"insert":"event","update":"event","remove":"event"}},"models":{"13b4415f6511c15":{"_id":"13b4415f6511c15","_name":"_Database","_core":true,"insert":{"description":"event send when a document is inserted in a collection","params":[{"name":"event","type":"dbInsertEvent"}]},"update":{"description":"event send when a document is updated in a collection","params":[{"name":"event","type":"dbUpdateEvent"}]},"remove":{"description":"event send when a document is removed from a collection","params":[{"name":"event","type":"dbRemoveEvent"}]}}},"behaviors":{"1de8c154bb18a01":{"_id":"1de8c154bb18a01","component":"_Database","state":"insert","action":"function insert(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\t\n}","useCoreAPI":false,"core":false},"173ff13cde1c29e":{"_id":"173ff13cde1c29e","component":"_Database","state":"remove","action":"function remove(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false},"1e0a71b78c1fd0e":{"_id":"1e0a71b78c1fd0e","component":"_Database","state":"update","action":"function update(event) { \n // always filter on the schema you want\n if (event.collection === '') {\n \n }\t\n}","useCoreAPI":false,"core":false}},"types":{"dbUpdateEvent":{"_id":"1f5c41309711752","name":"dbUpdateEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been updated","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been updated","type":"string","mandatory":true,"default":""},"field":{"description":"field of the document that has been updated","type":"string","mandatory":true,"default":""},"value":{"description":"value of the field of the document that has been updated","type":"any","mandatory":true,"default":null}}},"dbRemoveEvent":{"_id":"1952e1ac4213f4a","name":"dbRemoveEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been removed","type":"string","mandatory":true,"default":""},"id":{"description":"id of the document that has been removed","type":"string","mandatory":true,"default":""}}},"dbInsertEvent":{"_id":"148ef1e19810e6d","name":"dbInsertEvent","type":"object","schema":{"collection":{"description":"id of the collection where a document has been inserted","type":"string","mandatory":true,"default":""},"document":{"description":"document that has been inserted","type":"object","mandatory":true,"default":{}}}}},"components":{},"_id":"1d4431844018720"},"platform":"all"},"05-send-messages.json":{"_id":"05-send-messages.json","source":{"name":"send-messages","master":true,"version":"1.5.0","description":"Send messages through a channel\n\n\nYou can send messages into the current system or from one system to another system with channels. To do that:\n\n1. Define an event in '_Channel' schema and model.\n2. To listen to the message, just add a behavior to the event.\n3. To send a message: this.require('channel').myevent(param1, param2, ...).\n\n\nnote: see the tutorials for more informations.","schemas":{"104ad1f48518376":{"_id":"104ad1f48518376","_name":"_Channel","_inherit":["_Component"],"send":"event"}},"models":{"135c71078810af2":{"_id":"135c71078810af2","_name":"_Channel","send":{"description":"send a message","params":[{"name":"message","type":"message"}]}}},"behaviors":{"1ae8e11ece1a658":{"_id":"1ae8e11ece1a658","component":"_Channel","state":"send","action":"function send(message) { \n\n}","useCoreAPI":false,"core":false}},"types":{"message":{"name":"message","type":"object","schema":{"event":{"description":"name of the event","type":"string","mandatory":true},"from":{"description":"id of the system","type":"string","mandatory":false},"data":{"description":"arguments send to the event","type":"array","mandatory":true}},"core":true}},"components":{"_Channel":{"channel":{"_id":"channel"}}},"_id":"12eaf148b211195"},"platform":"all"}},"Language":{"language":{"_id":"language","target":"javascript"}},"MenuAction":{"j1b4981736918b41":{"_id":"j1b4981736918b41","html":"menu-action-back.html","position":10,"type":"designer"},"u18d911723019b96":{"_id":"u18d911723019b96","html":"menu-action-forward.html","position":20,"type":"designer"}},"MenuHeader":{"1fb101b99813a12":{"_id":"1fb101b99813a12","html":"menu-header.html","type":"designer"}},"MenuItem":{"14f481302c106e6":{"_id":"14f481302c106e6","name":"models","html":"menu-item-models.html","position":20,"type":"designer","platform":"all"},"14f481302c106e7":{"_id":"14f481302c106e7","name":"logs","html":"menu-item-logs.html","position":60,"type":"designer","platform":"all"},"154dd1323f1ffg0a":{"_id":"154dd1323f1ffg0a","name":"systems","html":"menu-item-system.html","position":10,"type":"designer","platform":"all"},"154dd1323f1ffg1a":{"_id":"154dd1323f1ffg1a","name":"schemas","html":"menu-item-schemas.html","position":10,"type":"designer","platform":"all"},"19ec81ce751e196":{"_id":"19ec81ce751e196","name":"components","html":"menu-item-components.html","position":50,"type":"designer","platform":"all"},"1eb9d188b11824c":{"_id":"1eb9d188b11824c","name":"behaviors","html":"menu-item-behaviors.html","position":40,"type":"designer","platform":"all"},"1fd911618e18ea9":{"_id":"1fd911618e18ea9","name":"types","html":"menu-item-types.html","position":30,"type":"designer","platform":"all"}},"MenuBar":{"menubar":{"_id":"menubar","actions":[],"header":"","items":[],"logo":""}},"Message":{"message":{"_id":"message"}},"Router":{"router":{"_id":"router"}},"Spaces":{"spaces":{"_id":"spaces","components":[],"items":[],"systems":[]}},"State":{"state":{"_id":"state","component":"","lastPage":"index.html","logs":[],"menu":"","messages":[],"navigation":{"menu":[],"spaces":[]},"previousMenu":"","space":"","type":"designer"}},"Store":{"store":{"_id":"store","collection":"","data":{},"extra":{},"uuid":""}},"SystemFactory":{"factory":{"_id":"factory","system":""}},"ToolBar":{"toolbar":{"_id":"toolbar","items":[]}},"Workspace":{"workspace":{"_id":"workspace"}},"MessageHelp":{"message-help":{"_id":"message-help"}},"_Storage":{"storage":{"_id":"storage","_core":true}},"ToolBarItem":{"1dbc51300e11z17":{"_id":"1dbc51300e11z17","html":"toolbar-item-search.html","position":35,"type":"designer","platform":"all"},"163a01b7ca1935c":{"_id":"163a01b7ca1935c","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"web"},"163a01b7ca1935e":{"_id":"163a01b7ca1935e","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"web"},"10bcb1a0511e09f":{"_id":"10bcb1a0511e09f","html":"toolbar-item-create.html","position":20,"type":"designer","platform":"all"},"13a291c27f16310":{"_id":"13a291c27f16310","html":"toolbar-item-copyright.html","position":90,"type":"designer","platform":"all"},"13a291c27f16314":{"_id":"13a291c27f16314","html":"toolbar-item-help.html","position":80,"type":"designer","platform":"all"},"13f70137b61b19b":{"_id":"13f70137b61b19b","html":"toolbar-item-publish.html","position":30,"type":"designer","platform":"all"},"163a01b7ca1935d":{"_id":"163a01b7ca1935d","html":"toolbar-item-import.html","position":45,"type":"designer","platform":"all"},"1dbc51200e116e11":{"_id":"1dbc51200e116e11","html":"toolbar-item-sync.html","position":65,"type":"designer","platform":"all"},"1dbc51200e116e3":{"_id":"1dbc51200e116e3","html":"toolbar-item-config.html","position":70,"type":"designer","platform":"all"},"y187401decb196c4":{"_id":"y187401decb196c4","html":"toolbar-item-export.html","position":50,"type":"designer","platform":"electron"},"x1371910b7812e58":{"_id":"x1371910b7812e58","html":"toolbar-item-refresh.html","position":40,"type":"designer","platform":"electron"},"g12f9e166c71cf91":{"_id":"g12f9e166c71cf91","html":"toolbar-item-extension.html","platform":"all","position":67,"type":"designer"},"l1f2871e69b1b85e":{"_id":"l1f2871e69b1b85e","html":"toolbar-item-command.html","platform":"all","position":37,"type":"designer"},"o195831c8251b34e":{"_id":"o195831c8251b34e","html":"toolbar-item-diagram.html","platform":"web","position":38,"type":"designer"},"t1bcd213629187e0":{"_id":"t1bcd213629187e0","html":"toolbar-item-diagram.html","platform":"electron","position":38,"type":"designer"}}},"_id":"e89c617b6b15d28"}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8a99ff8..7bb0288 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "system-designer-electron", - "version": "3.5.2", + "version": "3.5.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ecdacee..960c490 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "system-designer-electron", "productName": "System Designer", - "version": "3.5.2", + "version": "3.5.3", + "buildVersion": "353000", "description": "System Designer, an IDE for designing systems", "homepage": "https://designfirst.io/systemdesigner/", "author": "erwan carriou", diff --git a/scripts/linux.js b/scripts/linux.js index 41be3fe..505c229 100644 --- a/scripts/linux.js +++ b/scripts/linux.js @@ -32,7 +32,7 @@ const options = { overwrite: true, icon: 'Icon.png', appVersion: package.version, - buildVersion: 352000, + buildVersion: package.buildVersion, appCopyright: 'Copyright © 2019 Erwan Carriou.', ignore: ['node_modules'], afterCopy: [setLanguages([ diff --git a/scripts/macos.js b/scripts/macos.js index 58e5490..cd645c6 100644 --- a/scripts/macos.js +++ b/scripts/macos.js @@ -31,7 +31,7 @@ const options = { overwrite: true, icon: 'Icon.icns', appVersion: package.version, - buildVersion: 352000, + buildVersion: package.buildVersion, appCopyright: 'Copyright © 2019 Erwan Carriou.', ignore: ['node_modules'], afterCopy: [setLanguages([ @@ -42,7 +42,7 @@ const options = { packager(options) .then(path => console.log(`Successfully created System Designer package at ${path}`)) .catch((err) => { - console.error('Error creating macOS package:'); + console.error('Error creating Mac App Store package:'); console.error(err, err.stack); process.exit(1); }); \ No newline at end of file diff --git a/scripts/windows.js b/scripts/windows.js index 883d33f..866a2d0 100644 --- a/scripts/windows.js +++ b/scripts/windows.js @@ -31,7 +31,7 @@ const options = { overwrite: true, icon: 'Icon.ico', appVersion: package.version, - buildVersion: 352000, + buildVersion: package.buildVersion, appCopyright: 'Copyright © 2019 Erwan Carriou.', win32metadata: { FileDescription: 'An IDE for designing systems',